feat: built-in JSONL trace exporter via Hook (issue #942)#983
Open
park338 wants to merge 2 commits intoagentscope-ai:mainfrom
Open
feat: built-in JSONL trace exporter via Hook (issue #942)#983park338 wants to merge 2 commits intoagentscope-ai:mainfrom
park338 wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements a built-in, out-of-the-box local JSONL trace exporter for AgentScope-Java based on the existing
Hookevent system (issue #942).This makes it easy to dump a complete “LLM conversation + execution trace” to a local file for offline debugging / incident review / attaching to issues, without requiring Studio or custom hook code for every user.
Why
When troubleshooting Agent runs, users often need a simple, local, offline, file-based trace that includes:
Existing options (
JsonSession/Memory/Studio) are useful but not a direct substitute for a lightweight, portable audit log.Changes
Added built-in exporter:
agentscope-core/src/main/java/io/agentscope/core/hook/recorder/JsonlTraceExporter.javaPRE_CALL,POST_CALL,PRE_REASONING,POST_REASONING,PRE_ACTING,POST_ACTING,ERROR.includeReasoningChunks(true),.includeActingChunks(true),.includeSummary(true),.includeSummaryChunks(true)failFast(true)boundedElasticto avoid blocking agent execution threadstrace_id/span_idvia reflection when OpenTelemetry is present (no hard dependency)Added tests:
agentscope-core/src/test/java/io/agentscope/core/hook/recorder/JsonlTraceExporterTest.javaUpdated example to demonstrate usage:
agentscope-examples/quickstart/src/main/java/io/agentscope/examples/quickstart/HookExample.javaUpdated docs:
docs/en/task/hook.mddocs/zh/task/hook.mdOutput Format (JSONL)
Each line contains common fields like:
ts,event_type,agent_id,agent_namerun_id,turn_id,step_idtrace_id,span_idAnd event-specific payloads, e.g.:
input_messages(PreCall/PreReasoning/PreSummary)reasoning_message(PostReasoning)final_message(PostCall)tool_use/tool_result(Acting events)incremental_chunk/accumulated(chunk events)error_class/error_message/stacktrace(ErrorEvent)How To Use