Skip to content

Commit 578a4b6

Browse files
feat: add module, tool execution, and agent response attributes (#13)
* chore: Improve repository structure with templates and documentation organization - Add CODEOWNERS for automatic review assignment - Add issue templates (bug report, feature request) - Add pull request template with comprehensive checklist - Add pre-commit config with gitleaks, uv-lock, and ruff - Improve release-drafter.yml with more categories and better organization - Move AUTOMATION.md and ROADMAP.md to docs/ directory - Remove MERGE_BOT_GUIDE.md (content moved to AUTOMATION.md in English) - Update AUTOMATION.md with /update command documentation - Move Development section from README to CONTRIBUTING.md - Update ROADMAP version from v0.2.0 to v1.1.0 - Update all documentation references to new file locations * Fix merge-bot update command checkout issue The update command was failing because the checkout action wasn't specifying which repository to checkout from. This caused it to only fetch the default branches and not the PR branch. Added 'repository' parameter to the checkout action to explicitly specify the head repository, fixing the branch checkout issue. Same fix as applied to msgspec-ext repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add module, tool execution, and agent response attributes Add new attribute setters for: - Module attributes (name, type) for specialized visualizations - Extended tool attributes (execution type, protocol) - Extended agent attributes (response content) These attributes enable better categorization and visualization of AI operations in the msgtrace frontend. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c881495 commit 578a4b6

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/msgtrace/sdk/attributes.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,75 @@ def set_version(version: str):
449449
if span.is_recording():
450450
span.set_attribute("version", version)
451451

452+
# ========== Module Attributes ==========
453+
454+
@staticmethod
455+
def set_module_name(name: str):
456+
"""
457+
Set module name.
458+
459+
Args:
460+
name: Module name (e.g., 'vector_search', 'intent_classifier')
461+
"""
462+
span = trace.get_current_span()
463+
if span.is_recording():
464+
span.set_attribute("module.name", name)
465+
466+
@staticmethod
467+
def set_module_type(module_type: str):
468+
"""
469+
Set module type for specialized visualizations.
470+
471+
Args:
472+
module_type: Type (e.g., 'Agent', 'Tool', 'LLM', 'Transcriber', 'Retriever')
473+
"""
474+
span = trace.get_current_span()
475+
if span.is_recording():
476+
span.set_attribute("module.type", module_type)
477+
478+
# ========== Extended Tool Attributes ==========
479+
480+
@staticmethod
481+
def set_tool_execution_type(execution_type: str):
482+
"""
483+
Set tool execution type.
484+
485+
Args:
486+
execution_type: Execution type (e.g., 'local', 'remote')
487+
"""
488+
span = trace.get_current_span()
489+
if span.is_recording():
490+
span.set_attribute("gen_ai.tool.execution.type", execution_type)
491+
492+
@staticmethod
493+
def set_tool_protocol(protocol: str):
494+
"""
495+
Set tool protocol.
496+
497+
Args:
498+
protocol: Protocol (e.g., 'mcp', 'a2a', 'http', 'grpc')
499+
"""
500+
span = trace.get_current_span()
501+
if span.is_recording():
502+
span.set_attribute("gen_ai.tool.protocol", protocol)
503+
504+
# ========== Extended Agent Attributes ==========
505+
506+
@staticmethod
507+
def set_agent_response(response: str | dict[str, Any]):
508+
"""
509+
Set agent response content.
510+
511+
Args:
512+
response: Agent response as string or dict
513+
"""
514+
span = trace.get_current_span()
515+
if span.is_recording():
516+
if isinstance(response, str):
517+
span.set_attribute("gen_ai.agent.response", response)
518+
else:
519+
span.set_attribute("gen_ai.agent.response", json.dumps(response))
520+
452521
# ========== Generic Custom Attributes (MsgTrace) ==========
453522

454523
@staticmethod

0 commit comments

Comments
 (0)