Skip to content

Add AgentRuntime and strategy-based agent execution#27

Merged
JohnRichard4096 merged 7 commits intomainfrom
feat/agent-matcher
Mar 14, 2026
Merged

Add AgentRuntime and strategy-based agent execution#27
JohnRichard4096 merged 7 commits intomainfrom
feat/agent-matcher

Conversation

@JohnRichard4096
Copy link
Copy Markdown
Member

@JohnRichard4096 JohnRichard4096 commented Mar 14, 2026

Summary by Sourcery

Introduce a strategy-based agent execution architecture with AgentRuntime and AgentStrategy, refactor the built-in agent workflow into a reusable AmritaAgentStrategy integrated with ChatObject, and update configuration, templates, and docs to support the new agent runtime and simplified create_agent API.

New Features:

  • Add AgentRuntime and create_agent factory to provide a reusable, high-level agent runtime API over ChatObject and presets.
  • Introduce AgentStrategy, StrategyContext, and AmritaAgentStrategy to support pluggable, strategy-based agent execution modes including an agent-mixed strategy.
  • Add Jinja2-based prompt templating and default system prompt template for dynamic train message rendering.
  • Expose minimal_init helper for lightweight initialization flows.

Bug Fixes:

  • Tighten message list validation in libchat to reject invalid message item types and avoid silent acceptance of bad inputs.

Enhancements:

  • Refactor the built-in agent core into a strategy implementation that uses ToolsManager and StrategyContext, with clearer separation of concerns and improved error/limit handling.
  • Update MemoryLimiter to operate on Message objects, support configurable abstract instructions, and better handle token limiting, dropped messages, and rollback behavior.
  • Extend ChatObject to accept Message-based system prompts, integrate strategy execution into the main run flow, and support callback-based streaming and queue overflow handling.
  • Refine dependency resolution in the event matcher and deprecation metadata for legacy APIs.
  • Adjust default configuration by moving agent-related options into a dedicated BuiltinAgentConfig and tuning LLM memory abstraction defaults.

Build:

  • Bump project version to 0.6.0, add Jinja2 as a dependency, and remove the deprecated deprecated package from runtime dependencies.

Documentation:

  • Revise architecture documentation (EN/ZH) to describe the new entry layer with AgentRuntime, strategy-based execution flow, and layered design, including updated mermaid diagrams.
  • Update minimal example docs (EN/ZH) to use create_agent instead of manual ChatObject and preset setup, and clarify ChatObject’s role for advanced use cases.
  • Add concept docs for Agent Strategy (EN/ZH) and API reference pages for AgentRuntime, AgentStrategy, AmritaAgentStrategy, and StrategyContext, plus expand API index and navigation.
  • Clarify that the debug_log decorator is deprecated in favor of standard logging and update contributing guidelines with an AI-generated content policy.

Tests:

  • Rewrite and expand agent tests to cover the new strategy system, StrategyContext behavior, and AmritaAgentStrategy tool-calling scenarios and edge cases.
  • Add advanced tests for MemoryLimiter’s abstraction, token limiting, dropped messages, and exception-driven rollback.
  • Add advanced ChatObject tests for queue overflow, callbacks, full_response aggregation, message preparation, and callback reconfiguration errors.
  • Introduce libchat tests for text generation, message validation, adapter reflection, tools_caller, call_completion, and get_last_response behavior.
  • Tighten ToolsManager-related tests to enforce singleton cleanliness and decorator behavior across tests.

Chores:

  • Add a uv.lock file for dependency locking and update CONTRIBUTING with AI-generated content guidelines.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @JohnRichard4096, your pull request is larger than the review limit of 150000 diff characters

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 14, 2026

Deploying amritacore with  Cloudflare Pages  Cloudflare Pages

Latest commit: b3d57c0
Status: ✅  Deploy successful!
Preview URL: https://ed8eb057.amritacore.pages.dev
Branch Preview URL: https://feat-agent-matcher.amritacore.pages.dev

View logs

@JohnRichard4096
Copy link
Copy Markdown
Member Author

@sourcery-ai title

@sourcery-ai sourcery-ai Bot changed the title Feat/agent matcher Add AgentRuntime and strategy-based agent execution Mar 14, 2026
@JohnRichard4096
Copy link
Copy Markdown
Member Author

@sourcery-ai summary

@JohnRichard4096
Copy link
Copy Markdown
Member Author

@sourcery-ai review

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Mar 14, 2026

Sorry @JohnRichard4096, your pull request is larger than the review limit of 150000 diff characters

1 similar comment
@SourceryAI
Copy link
Copy Markdown

Sorry @JohnRichard4096, your pull request is larger than the review limit of 150000 diff characters

@JohnRichard4096 JohnRichard4096 merged commit c3853b6 into main Mar 14, 2026
3 of 4 checks passed
@JohnRichard4096 JohnRichard4096 deleted the feat/agent-matcher branch March 14, 2026 14:22
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