feat: Config-defined HTTP API allowlist (api_call tool)#61
Closed
feat: Config-defined HTTP API allowlist (api_call tool)#61
Conversation
Co-authored-by: KoheiYamashita <15520963+KoheiYamashita@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Feature] Implement secure execution for defined APIs
feat: Config-defined HTTP API allowlist (api_call tool)
Mar 16, 2026
Member
|
@copilot issueを最新化して |
Author
Issue 本文の更新を GitHub API で試しましたが、この実行環境の権限では Issue 編集が 403 でできませんでした。 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
📝 Description
Adds a new
api_calltool that lets the agent call only HTTP endpoints explicitly pre-approved inconfig.json. Unlikeweb_fetch, the LLM cannot reach arbitrary URLs. Auth headers (tokens, API keys) live exclusively in config and are never surfaced to the LLM.Config (
tools.apis):{ "tools": { "apis": [ { "name": "weather", "description": "Get current weather for a city", "url": "https://api.openweathermap.org/data/2.5/weather", "method": "GET", "headers": { "x-api-key": "SECRET_KEY" }, "params": [ { "name": "q", "in": "query", "description": "City name", "required": true } ], "timeout": 10 }, { "name": "create_task", "description": "Create a task", "url": "https://api.example.com/tasks", "method": "POST", "headers": { "Authorization": "******" }, "params": [ { "name": "title", "in": "body", "description": "Task title", "required": true } ] }, { "name": "get_user", "description": "Get user by ID", "url": "https://api.example.com/users/{user_id}", "method": "GET", "params": [ { "name": "user_id", "in": "path", "required": true } ] } ] } }Key changes:
pkg/config/config.go— AddedHTTPParam(name,in: query/body/path, description, required) andAPIEndpointConfig(name, url, method, headers, params, timeout) structs; addedAPIs []APIEndpointConfigtoToolsConfigpkg/tools/api_call.go— NewAPICallTool: LLM receives an enum of validapi_namevalues only; fixed headers injected server-side; supports query/path/body param routing;IsActive()hides the tool when no endpoints are configured; validates scheme (http/https only) and host after path expansionpkg/agent/loop.go— RegistersAPICallToolfor both main agent and subagents whencfg.Tools.APIsis non-emptypkg/tools/api_call_test.go— 13 tests covering: IsActive, param enum, GET/POST, query/path/body routing, fixed headers invisibility, missing required param, 4xx error propagation🗣️ Type of Change
🔗 Linked Issue
📚 Technical Context (Skip for Docs)
web_fetchallows the LLM to reach any URL; this feature scopes HTTP access to an explicit admin-controlled allowlist, enabling safe integrations (home automation, internal APIs, SaaS webhooks) without exposing credentials or allowing SSRF-class prompt injection.🧪 Test Environment & Hardware
📸 Proof of Work (Optional for Docs)
Click to view Logs/Screenshots
All 13 unit tests pass (
go test ./pkg/tools/... -run TestAPICallTool).go vet ./pkg/...clean. CodeQL: 0 alerts.☑️ Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.