Skip to content

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

Merged
merged 8 commits into from
Jul 7, 2025
Merged

Conversation

samchon
Copy link
Member

@samchon samchon commented Jul 7, 2025

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

Event Definitions

@samchon samchon self-assigned this Jul 7, 2025
@samchon samchon added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Jul 7, 2025
@samchon samchon added this to WrtnLabs Jul 7, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 and call 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 and correctJsonError to ensure malformed JSON is detected and handled correctly.
    const data: Record<string, unknown> = JSON.parse(toolCall.function.arguments);

@samchon samchon marked this pull request as ready for review July 7, 2025 07:19
Copy link

pkg-pr-new bot commented Jul 7, 2025

Open in StackBlitz

@agentica/benchmark

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/benchmark@473

@agentica/chat

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/chat@473

agentica

npm i https://pkg.pr.new/wrtnlabs/agentica@473

@agentica/core

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/core@473

create-agentica

npm i https://pkg.pr.new/wrtnlabs/agentica/create-agentica@473

@agentica/rpc

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/rpc@473

@agentica/vector-selector

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/vector-selector@473

commit: 724bf9f

@samchon samchon merged commit 691c74a into main Jul 7, 2025
13 checks passed
@samchon samchon deleted the feat/json branch July 7, 2025 07:42
@github-project-automation github-project-automation bot moved this to Done in WrtnLabs Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants