-
Notifications
You must be signed in to change notification settings - Fork 325
refactor tools #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor tools #731
Conversation
|
commit: |
Claude Code ReviewSummary: Clean refactoring that simplifies the human-in-the-loop API. The new Issues FoundCritical:
Moderate:
Minor:
Positive Changes
RecommendationFix issues #1-2 before merging (type safety + validation). Consider addressing #3 if backward compatibility matters. |
Syncs documentation changes from cloudflare/agents PR #731: - Add comprehensive useChat API reference documentation - Update human-in-the-loop guide to use new useChat hook - Replace two-hook pattern (useAgent + useAgentChat) with single useChat hook - Update tool configuration to use declarative confirm property - Simplify approval flow with approve() and deny() methods This is a breaking change that improves developer experience with: - Simpler single-hook API - Declarative tool configuration with execute and confirm properties - Cleaner approval flow without magic strings - Better TypeScript types with PendingConfirmation Related PR: cloudflare/agents#731 Generated with Claude Code https://claude.com/claude-code Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Add useChat hook that wraps useAgent + useAgentChat with simpler API - Support declarative tool configuration with confirm: true/false - Add approve()/deny() functions instead of addToolResult() with magic strings - Export pendingToolCalls array for easy UI rendering - Export TOOL_CONFIRMATION constants for protocol values - Update human-in-the-loop example to use new hook
1bc3ddf to
73dbfdc
Compare
Updates documentation to reflect the new simplified useChat hook that replaces the useAgent + useAgentChat pattern. ## Changes - Updated human-in-the-loop guide with new useChat hook examples - Added declarative Tool type documentation with confirm property - Documented new approve()/deny() API replacing addToolResult() - Added tool behavior matrix showing execute/confirm combinations - Updated WebSockets API reference to document both useAgent and useChat - Simplified code examples throughout ## Breaking Changes This documents the breaking changes introduced in cloudflare/agents#731: - useChat replaces useAgent + useAgentChat two-hook pattern - Tool type now uses declarative confirm property - approve(id) and deny(id) replace addToolResult() with magic strings - Simpler, more intuitive API for human-in-the-loop workflows 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Single source of truth for tool definitions (tools.ts) - Shared TOOL_CONFIRMATION constants between client/server - Derive toolsRequiringConfirmation from tool config (not hardcoded) - Add isLoading state to UseChatHelpers - Improved documentation with execution model table - Server.ts refactored with extracted metadata helper
- Move TOOL_CONFIRMATION constants to ai-types.ts (shared client/server) - Export from main index.ts for server-side use - Re-export from use-chat.tsx for client convenience - use-chat.tsx now imports from ai-types.ts (single source of truth) - Update example to document protocol requirement
Updates documentation to reflect the breaking changes in PR #731: - Replace useAgent + useAgentChat two-hook pattern with unified useChat hook - Update human-in-the-loop guide with new declarative tool configuration - Document new approve(id)/deny(id) API replacing addToolResult() - Add TOOL_CONFIRMATION protocol constants documentation - Update tool configuration to use confirm property instead of manual lists - Simplify examples to show new streamlined API This is a breaking change that affects how users implement human-in-the-loop workflows with the Agents SDK. Related PR: cloudflare/agents#731
disclaimer: this is breaking change, but man i think we need to clean this
Replaces the two-hook pattern (useAgent + useAgentChat) with a single useChat hook that provides: