Merged
Conversation
AgentMessage to ChatCompletionAgentMessage to ChatCompletion
There was a problem hiding this comment.
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
AgentMessagefields/methods for tool-calls, finish reasons, and conversion to/fromChatCompletion. - 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.
AgentMessage to ChatCompletion
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.
No description provided.