Skip to content

Refactor function calling#309

Merged
Harold-lkk merged 10 commits intomainfrom
refactor/function_call
Apr 20, 2026
Merged

Refactor function calling#309
Harold-lkk merged 10 commits intomainfrom
refactor/function_call

Conversation

@braisedpork1964
Copy link
Copy Markdown
Collaborator

No description provided.

@braisedpork1964 braisedpork1964 requested a review from Copilot April 20, 2026 05:56
@braisedpork1964 braisedpork1964 changed the title [WIP] Adapt AgentMessage to ChatCompletion Adapt AgentMessage to ChatCompletion Apr 20, 2026
Copy link
Copy Markdown

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 is working toward adapting AgentMessage/agent execution to better interoperate with OpenAI ChatCompletion-style responses, adding function-calling + tool execution plumbing and some new utility/actions to support that workflow.

Changes:

  • Add AgentMessage fields/methods for tool-calls, finish reasons, and conversion to/from ChatCompletion.
  • Update agent/memory/aggregator flows to support aborted-rollout resumption and tool-result messages.
  • Introduce new utilities and actions (text truncation, function-call agent, web visitor, MCP client, Async OpenAI wrapper).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
lagent/utils/util.py Extends create_object and adds truncate_text.
lagent/utils/__init__.py Exposes truncate_text via utils public API.
lagent/schema.py Extends AgentMessage + conversion helpers; adds tool_call_id to ActionReturn.
lagent/memory/base_memory.py Adds model-spec serialization/deserialization for stored messages; tweaks add/delete/load/save.
lagent/llms/openai.py Adds an AsyncOpenAIWrapper and new SDK imports.
lagent/agents/fc_agent.py Introduces function-call selection/env agents and tool prompt builder.
lagent/agents/aggregator/default_aggregator.py Adjusts aggregation to emit assistant/tool/user messages and includes extra_info.
lagent/agents/agent.py Adds aborted-rollout scroll/resume behavior and ChatCompletion-to-AgentMessage conversion.
lagent/actions/web_visitor.py Adds a web-visit + LLM-based extraction action.
lagent/actions/mcp_client.py Adds an MCP-backed async tool wrapper with rate limiting and concurrency control.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lagent/actions/mcp_client.py Outdated
Comment thread lagent/actions/web_visitor.py Outdated
Comment thread lagent/utils/util.py
Comment thread lagent/schema.py
Comment thread lagent/agents/fc_agent.py Outdated
Comment thread lagent/schema.py
Comment thread lagent/agents/aggregator/default_aggregator.py
Comment thread lagent/agents/fc_agent.py Outdated
Comment thread lagent/actions/mcp_client.py
Comment thread lagent/actions/mcp_client.py Outdated
@braisedpork1964 braisedpork1964 changed the title Adapt AgentMessage to ChatCompletion Refactor function calling Apr 20, 2026
@Harold-lkk Harold-lkk merged commit 0ab2e2f into main Apr 20, 2026
2 checks passed
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.

3 participants