Skip to content

Implement AgentService with tool calling loop#25

Merged
IreneXY merged 1 commit intomainfrom
031902
Mar 27, 2026
Merged

Implement AgentService with tool calling loop#25
IreneXY merged 1 commit intomainfrom
031902

Conversation

@IreneXY
Copy link
Copy Markdown
Member

@IreneXY IreneXY commented Mar 27, 2026

Summary

  • Add AgentService that orchestrates the tool calling cycle:
    LLM returns tool_calls → execute tools → send results back → LLM continues
  • Implements ChatService (decorator pattern): ChatBloc works transparently with either PortkeyChatService (no tools) or AgentService (with tools)
  • Constructor param named baseChatService to clarify the decoration relationship
  • Full streaming: every round streams events to UI
  • Max tool rounds configurable (default 5), emits ChatError when exceeded
  • Handles unknown tool names and tool execution errors gracefully
  • Add optional tools param to ChatService.chat(), PortkeyChatService, and PortkeyClient
  • Integration test: LLM calls an add tool, calculates 3+7=10

Test plan

  • dart analyze passes (chat_core + chat_adapter)
  • dart format --set-exit-if-changed . passes
  • dart test — chat_core: 58 tests passed (7 new), chat_adapter: 5 tests passed
  • Integration test: tool calling loop works end-to-end with real API

🤖 Generated with Claude Code

Co-Authored-By: Claude Code noreply@anthropic.com

Add AgentService that orchestrates the tool calling cycle:
- LLM returns tool_calls -> execute tools -> send results back -> LLM continues
- Implements ChatService (decorator pattern) so ChatBloc works with either
  PortkeyChatService (no tools) or AgentService (with tools) transparently
- Constructor param named baseChatService to clarify the decoration
- Full streaming: every round streams events to UI
- Max tool rounds configurable (default 5), emits ChatError when exceeded
- Handles unknown tool names and tool execution errors gracefully
- Add tools param to ChatService.chat(), PortkeyChatService, and PortkeyClient
- Integration test: LLM calls add tool, calculates 3+7=10

Co-Authored-By: Claude Code <noreply@anthropic.com>
@IreneXY IreneXY merged commit 31b75d7 into main Mar 27, 2026
1 check passed
@IreneXY IreneXY deleted the 031902 branch March 27, 2026 01:28
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.

2 participants