Skip to content

feat: chatagent callbacks and context clone#3950

Open
fengju0213 wants to merge 14 commits intomasterfrom
feat/chatagent-callbacks-context-clone
Open

feat: chatagent callbacks and context clone#3950
fengju0213 wants to merge 14 commits intomasterfrom
feat/chatagent-callbacks-context-clone

Conversation

@fengju0213
Copy link
Copy Markdown
Collaborator

@fengju0213 fengju0213 commented Mar 20, 2026

Related Issue

Closes #

Description

  • Introduce AgentCallback / AgentEvent interface with 6 lifecycle events (step_started, step_completed, step_failed, tool_started, tool_completed, tool_failed), fired across all execution paths (non-streaming, streaming sync, streaming async)
  • Add execution_context (static dict) and execution_context_provider (dynamic callable) to ChatAgent, merged into every event's metadata
  • Preserve contextvars context when sync tools are dispatched to thread pools — covers FunctionTool.async_call, _aexecute_tool, _aexecute_tool_from_stream_data, and step() timeout path
  • Enhance clone() to accept CloneContext(session_id, execution_context), preserve full runtime config, deep-copy stateful response_terminators, and forward session_id to toolkit clone_for_new_session()

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Checklist

  • I have read and agree to the AI-Generated Code Policy (required)
  • I have linked this PR to an issue (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and run uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed
  • I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

@fengju0213 fengju0213 marked this pull request as draft March 20, 2026 07:19
@github-actions github-actions bot added the Review Required PR need to be reviewed label Mar 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 20, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eb9e3d6c-6e21-4fe6-9225-4f11a1723e15

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chatagent-callbacks-context-clone

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fengju0213 fengju0213 marked this pull request as ready for review March 24, 2026 06:12
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review Required PR need to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add lifecycle callbacks, execution context propagation, and improved clone semantics to ChatAgent

2 participants