Skip to content

[dotnet-port-api] Add agent-as-tool argument name/description customization - #1157

Open
PratikDhanave (PratikDhanave) wants to merge 1 commit into
microsoft:mainfrom
PratikDhanaveFork:feat/agenttool-arg-customization
Open

PratikDhanave (PratikDhanave) wants to merge 1 commit into
microsoft:mainfrom
PratikDhanaveFork:feat/agenttool-arg-customization

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Partial implementation of #1139.

agenttool hardcoded a single query string argument with a fixed description. Add ArgName and ArgDescription config 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") and Config.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).
  • Defaults are unchanged, so existing behavior and tests are unaffected.

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 Call time needs a mechanism the tool interface does not currently expose.

Test

  • TestNew_CustomArgNameAndDescription: a custom ArgName:"task" is reflected in the schema (and the default query is gone), and Call with {"task":...} forwards the value to the agent. Fails to build before the change (fields absent), passes after.

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).
Copilot AI lite review requested due to automatic review settings September 22, 2026 05:24
@github-actions github-actions Bot added area:tool Changes files in the tool area size:medium At most 100 changed lines across at most 5 files labels Sep 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

Open (1)
What changed in this PR

Adds configurable argument names and descriptions to agenttool, preserving existing defaults.

Changes:

  • Added ArgName and ArgDescription configuration.
  • 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.

Comment on lines +118 to +122
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)
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Scope: public API, user-visible behavior

Changed Go contract: agenttool.Config gains two new exported fields, ArgName (default "query") and ArgDescription (default "input query to invoke the agent"), used by Schema() (property name/description, required) and Call() (map-key lookup instead of a fixed Query struct field). Defaults are unchanged from pre-PR behavior.

Upstream evidence reviewed:

  • Python python/packages/core/agent_framework/_agents.py, Agent.as_tool() (~line 641): exposes arg_name: str = "task" and arg_description: str | None = None (defaults to f"Task for {tool_name}"), builds input_schema["properties"][arg_name] and required=[arg_name] — the same customization concept the Go PR adds.
  • .NET dotnet/src/Microsoft.Agents.AI/AgentExtensions.cs, AIAgentExtensions.AsAIFunction() (~line 66-86): the parameter is a hardcoded local-function parameter named query with a fixed [Description("Input query to invoke the agent.")] attribute; AIFunctionFactoryOptions only lets callers override the function's Name/Description, not the argument name/description. .NET currently has no equivalent argument-customization knob.

Result: aligned (with one non-blocking note). The Go change is a legitimate, additive port of Python's arg_name/arg_description option onto the existing .NET-mirrored default ("query" / "input query to invoke the agent"), and defaults are preserved so existing callers are unaffected. Note for maintainers: the PR description says this "mirrors the .NET/Python as-tool argument options," but .NET does not actually expose an equivalent option today — only Python does. This isn't a parity defect (Go is simply ahead of .NET here, matching Python), just a description nit worth correcting for accuracy. No behavioral or default divergence was found relative to either upstream implementation.

Since this PR adds new exported Config fields, flagging for a public API review via public-api-change. No cross-repo consistency issues found, so also marking parity-approved.

Generated by Go API Consistency Review Agent · copilot · auto · 66.4 AIC · ⌖ 5.97 AIC · ⊞ 9.2K · ◷

@github-actions github-actions Bot added parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs labels Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tool Changes files in the tool area kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants