mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 00:16:46 +00:00
Skip trace work when disabled; share the agent span builder
With TRACES_ENABLED off, LLM calls record no GenAI metrics, and a streamed answer is joined into a preview only when a span keeps it. Agent runs and continuations build their invoke_agent span in one place, which now reads the model from model_id. The trace panel shows a stream's model time next to how long it was open. Adds missing type hints.
This commit is contained in:
1 parent
699906a015
commit
0bbbac0eb2
18 files changed
+88
-35
No files matched your search
+2
-17
@@ -32,7 +32,7 @@ from docsgpt.guardrails.stream import StreamingOutputGuard
|
||||
from docsgpt.guardrails.types import Action, Stage, resolve_tool_result
|
||||
from docsgpt.llm.handlers.handler_creator import LLMHandlerCreator
|
||||
from docsgpt.llm.llm_creator import LLMCreator
|
||||
from docsgpt.logging import build_stack_data, log_activity, LogContext
|
||||
from docsgpt.logging import build_stack_data, log_activity, LogContext, start_agent_span
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -504,22 +504,7 @@ class BaseAgent(ABC):
|
||||
pending_tool_calls: The pending tool call descriptors from the pause.
|
||||
tool_actions: Client-provided actions resolving the pending calls.
|
||||
"""
|
||||
label = type(self).__name__
|
||||
span = tracing.start_span(
|
||||
tracing.KIND_AGENT,
|
||||
f"invoke_agent {label}",
|
||||
attributes={
|
||||
k: v
|
||||
for k, v in {
|
||||
"gen_ai.operation.name": "invoke_agent",
|
||||
"gen_ai.agent.id": str(self.agent_id) if getattr(self, "agent_id", None) else None,
|
||||
"gen_ai.request.model": getattr(self, "model_id", None),
|
||||
"docsgpt.agent_type": label,
|
||||
"docsgpt.continuation": True,
|
||||
}.items()
|
||||
if v is not None
|
||||
},
|
||||
)
|
||||
span = start_agent_span(self, continuation=True)
|
||||
completed = False
|
||||
try:
|
||||
yield from self._gen_continuation_inner(
|
||||
|
||||
Reference in new issue
Block a user