feat(ptc): 实现 Programmatic Tool Calling 完整支持#9
Merged
Merged
Conversation
实现了 Anthropic PTC 协议扩展,允许 LLM 生成的 Python 代码直接调用 Aster 工具。 核心功能: - HTTP 桥接服务器,提供 REST API 供 Python 调用 - Python SDK (aiohttp),带重试和错误处理 - AllowedCallers 配置,精确控制工具调用权限 - Schema 缓存和 Keep-Alive 优化 - 完整的文档和示例 新增文件: - pkg/tools/bridge/http_server.go: HTTP 桥接服务器实现 - pkg/tools/bridge/ptc_integration_test.go: 集成测试 - client-sdks/python-bridge/aster.py: Python SDK - docs/content/05.tools/5.ptc/: 完整文档(快速开始、高级用法、架构、故障排除) - examples/ptc/: 三个示例程序(basic, file-processor, local-test) 修改文件: - pkg/provider/anthropic.go: 支持 AllowedCallers 和 Caller 字段 - pkg/provider/interface.go: 扩展 ToolSchema 和 ToolUseBlock - pkg/tools/bridge/runtime.go: 注入增强的 Python SDK - pkg/tools/builtin/codeexecute.go: 集成 ToolBridge - pkg/types/message.go: 支持 Caller 跟踪 技术亮点: - 指数退避重试 (3 次, 0.5s/1s/2s) - 智能错误分类 (网络错误重试, 工具错误不重试) - Schema 缓存 (5分钟 TTL, 并发安全) - HTTP 连接复用 (120s Keep-Alive) - 完整的错误处理和日志记录 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
实现了 Anthropic PTC 协议扩展,允许 LLM 生成的 Python 代码直接调用 Aster 工具。
核心功能:
新增文件:
修改文件:
技术亮点:
🤖 Generated with Claude Code