[Feature] Support tool parameter injection#854
Conversation
b2f9753 to
0a18129
Compare
0a18129 to
17b0f9a
Compare
53f537c to
28ab27d
Compare
|
Hi, @Sxnan and @wenjin272. Could you please review this PR? Thank you! |
|
Thanks for the work — the schema-hiding part ( A step back on the API shape before line details: #853 asks for one narrow thing — inject a model-hidden, framework-owned arg at execution time. This PR does it via a general before/after hook mechanism (hook slots on
Suggestion:
If there's a concrete need behind the general hooks that isn't in #853, worth surfacing here. |
d3295ca to
d71b52f
Compare
Thanks, agreed with the direction here. Stepping back, #853 should stay focused on model-hidden framework-owned argument injection, and the generic before/after hook mechanism was too broad for that scope. I’ve updated the PR accordingly:
So the PR now covers only the narrow injection use case from #853. Any general |
d71b52f to
3369917
Compare
e73d1fd to
74d5ea3
Compare
There was a problem hiding this comment.
@GreatEugenius, thanks for taking this on. Overall looks good to me, I left two comments.
Besides, I think we also need add e2e case for YAML API.
Sxnan
left a comment
There was a problem hiding this comment.
Two follow-ups, verified against the implementations. Neither blocks the common scalar-injection path.
74d5ea3 to
17ac568
Compare
|
Hi @wenjin272 and @Sxnan, I have addressed your comment. Please review it once more. |
1bc213e to
f78f835
Compare
Sxnan
left a comment
There was a problem hiding this comment.
One more cross-language gap, verified against the implementations: injected-arg declarations don't travel across the language bridge — schema hiding and injection only honor the host-language declaration.
f78f835 to
0b5bf5a
Compare
|
Hi @Sxnan and @wenjin272. Thanks for pointing this out. I fixed this by carrying injected tool args through the cross-language metadata bridge in both directions. For Python host -> Java tool, For Java host -> Python tool, So the cross-language behavior is now aligned: injected params are hidden from the model schema and are also available to the host-language |
Linked issue: #853
Purpose of change
Support declarative tool parameter injection for function tools.
This change lets framework-owned arguments, such as tenant id or request context, be injected at tool execution time without exposing them to the model-facing tool schema. The injection source is declared together with the hidden tool parameter, and values are resolved by the built-in
tool_call_actionimmediately before invoking the tool.Main changes:
Add Python API support:
@tool(injected_args={"tenant_id": InjectedArg.from_config("tenant_id")})Add Java API support:
@ToolParam(injected = true, source = ToolParameterSource.CONFIG, key = "tenant_id")Add YAML API support:
tools[].injected_argsas an object mapping parameter names to injection specsInject parameters in the built-in
tool_call_action, after reading model arguments and before invoking the tool.Preserve injected argument metadata in the plan/runtime representation while filtering injected parameters from model-facing tool metadata.
Keep cross-language tool calls supported by resolving injection before dispatching to the target tool implementation.
Tests
UT & E2E Test
API
Yes
Documentation
doc-neededdoc-not-neededdoc-included