-
Notifications
You must be signed in to change notification settings - Fork 46
feat(agent): new event type, AgenticaJsonParseErrorEvent
#473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds full support for handling JSON parsing errors in function call arguments by introducing a new event type, system prompts, and correction logic across the orchestrator.
- Defined
AgenticaJsonParseErrorEvent
and integrated it into event unions - Extended system prompt interfaces and constants with
jsonParseError
- Updated orchestrator (
callee
andcall
pipelines) to detect, dispatch, and correct malformed JSON before validation
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/core/src/structures/IMicroAgenticaSystemPrompt.ts | Added jsonParseError prompt signature and import |
packages/core/src/structures/IAgenticaSystemPrompt.ts | Added jsonParseError prompt signature and import |
packages/core/src/orchestrate/callee.ts | Implemented parseArguments , correctJsonError , and JSON error retry logic |
packages/core/src/orchestrate/call.ts | Swapped createCallEvent for parseArguments and supported JSON error propagation |
packages/core/src/factory/events.ts | Added createJsonParseErrorEvent factory function |
packages/core/src/events/index.ts | Re-exported AgenticaJsonParseErrorEvent |
packages/core/src/events/MicroAgenticaEvent.ts | Included JSON parse error in MicroAgenticaEvent union |
packages/core/src/events/AgenticaJsonParseErrorEvent.ts | Defined AgenticaJsonParseErrorEvent interface |
packages/core/src/events/AgenticaEvent.ts | Added JSON parse error to AgenticaEvent union |
packages/core/src/constants/AgenticaSystemPrompt.ts | Added JSON_PARSE_ERROR prompt template |
packages/core/prompts/json_parse_error.md | Provided detailed prompt for JSON parsing errors |
Comments suppressed due to low confidence (2)
packages/core/src/orchestrate/callee.ts:591
- Duplicate definition of
parseArguments
in this file; remove the redundant function to avoid name collisions and unexpected behavior.
function: {
packages/core/src/orchestrate/callee.ts:487
- Consider adding unit tests for the JSON parse error flow, covering
parseArguments
andcorrectJsonError
to ensure malformed JSON is detected and handled correctly.
const data: Record<string, unknown> = JSON.parse(toolCall.function.arguments);
@agentica/benchmark
@agentica/chat
agentica
@agentica/core
create-agentica
@agentica/rpc
@agentica/vector-selector
commit: |
This pull request introduces comprehensive handling for JSON parsing errors in function call arguments across the codebase. It includes updates to error messaging, event definitions, and prompts to ensure proper handling and communication of invalid JSON syntax issues.
JSON Parsing Error Handling
packages/core/prompts/json_parse_error.md
: Added a detailed prompt for handling JSON parsing errors, including error description, required actions, and common syntax requirements.packages/core/src/constants/AgenticaSystemPrompt.ts
: Added a new system prompt (JSON_PARSE_ERROR
) to guide users in resolving JSON syntax errors in function call arguments.Event Definitions
packages/core/src/events/AgenticaEvent.ts
: Introduced a new event typeAgenticaJsonParseErrorEvent
and added it to theAgenticaEvent
union type and namespace. [1] [2] [3]packages/core/src/events/AgenticaJsonParseErrorEvent.ts
: Defined theAgenticaJsonParseErrorEvent
interface, including properties for operation details, arguments, and error messages.packages/core/src/events/MicroAgenticaEvent.ts
: AddedAgenticaJsonParseErrorEvent
to theMicroAgenticaEvent
union type for micro-event handling. [1] [2]