[dotnet-port-api] Add agent-as-tool argument name/description customization - #1157
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Conversation
agenttool hardcoded a single "query" string argument. Add ArgName and ArgDescription config options (defaulting to "query" / "input query to invoke the agent") so callers can rename/re-describe the argument the model sees, mirroring the .NET/Python as-tool argument options. The schema and Call now use the configured name. Partial for microsoft#1139 (session propagation is left for the design discussion on that issue).
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Invalid non-string argument values are silently converted into blank queries instead of returning decoding errors.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Adds configurable argument names and descriptions to agenttool, preserving existing defaults.
Changes:
- Added
ArgNameandArgDescriptionconfiguration. - Updated schema generation and argument forwarding.
- Added custom-argument tests.
| File | Description |
|---|---|
tool/agenttool/agenttool.go |
Implements configurable argument metadata and invocation. |
tool/agenttool/agenttool_test.go |
Tests custom schema and argument forwarding. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| var in map[string]any | ||
| if err := json.Unmarshal([]byte(args), &in); err != nil { | ||
| return nil, err | ||
| } | ||
| resp, err := t.agent.RunText(ctx, in.Query, t.opts...).Collect() | ||
| query, _ := in[t.argName].(string) |
|
Scope: public API, user-visible behavior Changed Go contract: Upstream evidence reviewed:
Result: aligned (with one non-blocking note). The Go change is a legitimate, additive port of Python's Since this PR adds new exported
|

Partial implementation of #1139.
agenttoolhardcoded a singlequerystring argument with a fixed description. AddArgNameandArgDescriptionconfig options so a caller can rename/re-describe the argument the model sees — mirroring the .NET/Python as-tool argument options.Change
Config.ArgName(default"query") andConfig.ArgDescription(default"input query to invoke the agent").Schema()emits the configured argument name/description;Call()reads the configured key (decoding into a map rather than a fixed struct field).Scoped to the argument customization; session propagation (the other half of #1139) is left for the design discussion there, since obtaining the caller session at
Calltime needs a mechanism the tool interface does not currently expose.Test
TestNew_CustomArgNameAndDescription: a customArgName:"task"is reflected in the schema (and the defaultqueryis gone), andCallwith{"task":...}forwards the value to the agent. Fails to build before the change (fields absent), passes after.