Skip to content

refactor: adapt listen chat agent to camel callbacks#1507

Draft
fengju0213 wants to merge 2 commits intomainfrom
plan
Draft

refactor: adapt listen chat agent to camel callbacks#1507
fengju0213 wants to merge 2 commits intomainfrom
plan

Conversation

@fengju0213
Copy link
Collaborator

@fengju0213 fengju0213 commented Mar 20, 2026

Related Issue

Closes # #1502

Description

Replaces ListenChatAgent's override-based lifecycle hooks with CAMEL's new AgentCallback / AgentEvent framework (camel-ai/camel#XXX).

Before: ListenChatAgent overrode step, astep, _execute_tool, _aexecute_tool to manually emit activate/deactivate actions to the frontend. This duplicated ~400 lines of CAMEL internals (tool dispatch, mask handling, result truncation, error handling) and broke on every upstream change.

After: All lifecycle-to-frontend bridging is handled by ListenChatAgentCallback, a standard AgentCallback that receives events from CAMEL and translates them to Eigent task actions. ListenChatAgent no longer reimplements CAMEL's tool execution or step logic.

Changes

listen_chat_agent.py (-557 / +228)

  • Remove overrides of step, astep inner logic — now just wrap super() with set_process_task context and handle streaming re-wrapping
  • Remove complete reimplementations of _execute_tool / _aexecute_tool — now delegate to super() with pre/post event emission
  • Wire ListenChatAgentCallback + execution_context + execution_context_provider into super().__init__ via CAMEL's new constructor params
  • clone() updated to forward CloneContext and preserve new runtime config fields (retry_attempts, retry_delay, callbacks, execution_context, execution_context_provider, summary_window_ratio)

listen_chat_agent_callback.py (+276, new file)

  • ListenChatAgentCallback(AgentCallback) — translates 6 CAMEL lifecycle events into Eigent task queue actions:
    • StepStartedActionActivateAgentData
    • StepCompletedActionDeactivateAgentData (with token count)
    • StepFailedActionBudgetNotEnough + ActionDeactivateAgentData
    • ToolStartedActionActivateToolkitData
    • ToolCompletedActionDeactivateToolkitData
    • ToolFailedActionDeactivateToolkitData
  • Preserves __listen_toolkit__ decorator skip logic
  • Preserves toolkit name resolution chain (attribute → __self__ → nested func.__self__ → fallback mcp_toolkit)
  • Includes fallback dataclass definitions for when CAMEL types aren't importable

test_listen_chat_agent.py (-15 / +107)

  • Existing step/astep tests updated to assert set_process_task context instead of internal put_queue calls
  • New: test_listen_chat_agent_callback_handles_step_events — verifies activate/deactivate queue actions for step lifecycle
  • New: test_listen_chat_agent_callback_handles_budget_failure — verifies budget exceeded triggers both ActionBudgetNotEnough and deactivate
  • Clone test updated to pass CloneContext

Testing Evidence (REQUIRED)

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@fengju0213 fengju0213 self-assigned this Mar 20, 2026
@fengju0213 fengju0213 added this to the Sprint 19 milestone Mar 20, 2026
@fengju0213 fengju0213 marked this pull request as draft March 20, 2026 07:48
@fengju0213
Copy link
Collaborator Author

image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add the missing extension seams in CAMEL so applications like eigent can use upstream ChatAgent / Workforce directly

1 participant