-
Notifications
You must be signed in to change notification settings - Fork 762
[tiny-agents] Handle env variables in tiny-agents (Python client) #3129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds an interactive prompt to forward local environment variables when agent.json
sets them to null
.
- Introduces logic in the CLI to detect
null
env vars, prompt the user, and inject local values on consent - Imports
os
to access the host environment - Changes two
break
statements toreturn
for early exit whenexit_event
is set
Comments suppressed due to low confidence (3)
src/huggingface_hub/inference/_mcp/cli.py:72
- Consider adding tests for both user consent and denial paths when forwarding environment variables, to ensure this interactive flow behaves as expected.
# Handle env variable injection if required
src/huggingface_hub/inference/_mcp/cli.py:133
- Replacing
break
withreturn
will exit the entire function instead of just the loop. Confirm this early return won’t skip necessary cleanup or downstream logic.
return
src/huggingface_hub/inference/_mcp/cli.py:153
- This
return
mirrors the change above in a nested loop; ensure that prematurely exiting here doesn’t interfere with any remaining streaming or cleanup steps.
return
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for forwarding user-provided or environment‐derived inputs into the agent’s server configurations.
- Introduces an
inputs
processing step before the main agent loop, prompting the user and injecting values into server envs. - Adjusts loop exit behavior by replacing inner
break
calls withreturn
.
Comments suppressed due to low confidence (1)
src/huggingface_hub/inference/_mcp/cli.py:74
- There are no tests covering the new
inputs
prompting and env-injection logic; consider adding unit tests or integration tests to verify the user prompt flow and environment variable fallback behavior.
if len(inputs) > 0:
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Thanks for adding this
Thanks! Merging it now :) (still possible to iterate later) |
key | ||
for server in servers | ||
for key, value in server.get("config", {}).get("env", {}).items() | ||
if value == env_special_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potentially, you should also check config.headers
: for HTTP or SSE servers it's expected most keys will end up in headers.
see related doc PR from me here: microsoft/vscode-docs#8437
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but not prio at all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've pushed something on your JS PR actually:
huggingface/huggingface.js@d154e3e
(see the comments there..)
This PR adds support for the inputs configuration defined by VSCode (see [docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server-to-your-workspace)). PR adapted from huggingface/huggingface_hub#3129 using Cursor. Made some minor adjustments manually. ### How to test ``` pnpm run cli run wauplin/library-pr-reviewer ```  --------- Co-authored-by: Julien Chaumond <julien@huggingface.co>
This PR adds support for the
inputs
configuration defined by VSCode (see docs).We do not support all the VSCode feature but follow their convention. In practice:
input.id
andinput.description
must be set => used to prompt userintput.type
/input.password
=> not usedExample
Here is an example (library-pr-reviewer/agent.json):