Skip to content

feat: ActionAgent DO with tool-use chat via Agents SDK - #75

Merged
chitcommit merged 1 commit into
mainfrom
feat/action-agent-sdk
Mar 29, 2026
Merged

chitcommit merged 1 commit into
mainfrom
feat/action-agent-sdk

Conversation

@chitcommit

@chitcommit chitcommit commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds ActionAgent Durable Object using Cloudflare Agents SDK (AIChatAgent) with Workers AI (Llama 3.3 70B)
  • 11 tools: 7 financial (snapshot, obligations, disputes, recommendations, approve_action, legal deadlines, cashflow) + 4 ChittyStorage (search, classify, list, ingest via storage.chitty.cc/mcp)
  • Persistent per-user chat history in DO SQLite, mounted at /agent/* behind existing authMiddleware
  • Upgraded zod v3 → v4 (required by agents SDK, backward compatible — @hono/zod-validator supports both)

Test plan

  • npm run typecheck passes (verified locally)
  • npm run dev starts, /health still responds
  • WebSocket to /agent/ActionAgent/{userId} connects and streams tool-use responses
  • Existing REST routes (/api/*) and MCP (/mcp) unaffected
  • Deploy succeeds with new DO binding + SQLite migration

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added an AI-powered conversational agent with tool integration for financial operations and document management.
    • Agent can query financial data, view recommendations, and approve actions with database persistence.
    • Integrated document search and classification capabilities.
    • New authenticated endpoint for agent interactions.
  • Chores

    • Updated dependencies to support AI and agent functionality.
    • Added infrastructure configuration for agent persistence.

Integrate Cloudflare Agents SDK to provide a persistent conversational
agent with financial tool-use and ChittyStorage document access. Each
authenticated user gets an isolated DO instance with auto-persisted
chat history in SQLite.

- ActionAgent (AIChatAgent<Env>) with Workers AI (Llama 3.3 70B)
- 7 financial tools: snapshot, obligations, disputes, recommendations,
  approve_action, legal deadlines, cashflow projections
- 4 storage tools: search, classify, list entity docs, ingest
  (proxied to storage.chitty.cc MCP endpoint)
- Mounted at /agent/* behind existing authMiddleware
- Upgraded zod v3 → v4 (required by agents SDK, backward compatible)
- Added deps: @cloudflare/ai-chat, hono-agents, workers-ai-provider, ai@6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
chittycommand-ui f85414e Mar 29 2026, 05:36 AM

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chitcommit
chitcommit merged commit fbd802c into main Mar 29, 2026
12 of 14 checks passed
@github-actions

Copy link
Copy Markdown
  1. @coderabbitai review
  2. @copilot review
  3. @codex review
  4. @claude review
    Adversarial review request: evaluate security, policy bypass paths, regression risk, and merge-gating bypass attempts.

@chitcommit
chitcommit deleted the feat/action-agent-sdk branch March 29, 2026 05:36
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a999fe01-7701-4921-b4ba-0ed189b147bb

📥 Commits

Reviewing files that changed from the base of the PR and between 37d2b46 and f85414e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • package.json
  • src/agents/action-agent.ts
  • src/agents/system-prompt.ts
  • src/agents/tools/financial.ts
  • src/agents/tools/storage.ts
  • src/index.ts
  • wrangler.toml

📝 Walkthrough

Walkthrough

A new AI-powered agent system is introduced with multi-turn conversation support, integrating Cloudflare Workers AI and Durable Objects. The system includes database-backed financial tools for querying obligations, recommendations, and cashflow, plus remote document storage tools via an MCP client. Agent middleware is configured for authenticated access to the agent endpoint.

Changes

Cohort / File(s) Summary
Agent Framework
src/agents/action-agent.ts, src/agents/system-prompt.ts
New ActionAgent class implementing persistent, tool-using chat with dynamic system prompts built from live financial data; buildSystemPrompt function queries databases for cash, obligations, disputes, and legal deadlines.
Agent Tools
src/agents/tools/financial.ts, src/agents/tools/storage.ts
Financial tools provide database-backed reads/writes for snapshots, obligations, disputes, recommendations, and legal deadlines; storage tools implement JSON-RPC client for remote document operations via MCP endpoint.
Infrastructure & Configuration
src/index.ts, wrangler.toml, package.json
Integrated agentsMiddleware on /agent/* route, re-exported ActionAgent, added ACTION_AGENT Durable Object binding to Env type, configured Durable Object in wrangler.toml, and added AI/agent npm dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ActionAgent
    participant SystemPrompt
    participant WorkersAI
    participant Database
    participant StorageMCP
    
    Client->>ActionAgent: POST /agent/* (chat message)
    ActionAgent->>Database: getDb() connection
    ActionAgent->>SystemPrompt: buildSystemPrompt(sql)
    SystemPrompt->>Database: Query financial data<br/>(cash, obligations, disputes, deadlines)
    Database-->>SystemPrompt: Financial snapshot
    SystemPrompt-->>ActionAgent: Dynamic system prompt
    ActionAgent->>WorkersAI: createWorkersAI(llama-3.3-70b)
    ActionAgent->>ActionAgent: convertToModelMessages(history)
    ActionAgent->>WorkersAI: streamText(prompt, tools, history)
    WorkersAI->>WorkersAI: Generate response with tool calls
    WorkersAI->>Database: Tool execution (financial tools)
    Database-->>WorkersAI: Query results
    WorkersAI->>StorageMCP: Tool execution (storage tools)
    StorageMCP-->>WorkersAI: MCP response
    WorkersAI-->>ActionAgent: Streamed text + tool results
    ActionAgent-->>Client: toUIMessageStreamResponse()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A chat with tools now springs to life,
Financial queries end the strife,
With Workers AI and SQL's might,
Agents draft responses bright,
Durable Objects hold the day—
Chitty's wisdom now can play! 🎩✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/action-agent-sdk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant