refactor: adapt listen chat agent to camel callbacks#1507
Draft
fengju0213 wants to merge 2 commits intomainfrom
Draft
refactor: adapt listen chat agent to camel callbacks#1507fengju0213 wants to merge 2 commits intomainfrom
fengju0213 wants to merge 2 commits intomainfrom
Conversation
Collaborator
Author
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.

Related Issue
Closes # #1502
Description
Replaces
ListenChatAgent's override-based lifecycle hooks with CAMEL's newAgentCallback/AgentEventframework (camel-ai/camel#XXX).Before:
ListenChatAgentoverrodestep,astep,_execute_tool,_aexecute_toolto 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 standardAgentCallbackthat receives events from CAMEL and translates them to Eigent task actions.ListenChatAgentno longer reimplements CAMEL's tool execution or step logic.Changes
listen_chat_agent.py(-557 / +228)step,astepinner logic — now just wrapsuper()withset_process_taskcontext and handle streaming re-wrapping_execute_tool/_aexecute_tool— now delegate tosuper()with pre/post event emissionListenChatAgentCallback+execution_context+execution_context_providerintosuper().__init__via CAMEL's new constructor paramsclone()updated to forwardCloneContextand 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:StepStarted→ActionActivateAgentDataStepCompleted→ActionDeactivateAgentData(with token count)StepFailed→ActionBudgetNotEnough+ActionDeactivateAgentDataToolStarted→ActionActivateToolkitDataToolCompleted→ActionDeactivateToolkitDataToolFailed→ActionDeactivateToolkitData__listen_toolkit__decorator skip logic__self__→ nestedfunc.__self__→ fallbackmcp_toolkit)test_listen_chat_agent.py(-15 / +107)set_process_taskcontext instead of internalput_queuecallstest_listen_chat_agent_callback_handles_step_events— verifies activate/deactivate queue actions for step lifecycletest_listen_chat_agent_callback_handles_budget_failure— verifies budget exceeded triggers bothActionBudgetNotEnoughand deactivateCloneContextTesting Evidence (REQUIRED)
What is the purpose of this pull request?
Contribution Guidelines Acknowledgement