fix: support Google Colab secrets for HF_TOKEN loading#678
Merged
sergiopaniego merged 2 commits intoApr 27, 2026
Merged
Conversation
pcuenca
reviewed
Apr 23, 2026
pcuenca
approved these changes
Apr 23, 2026
Collaborator
|
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. |
sergiopaniego
approved these changes
Apr 27, 2026
Member
sergiopaniego
left a comment
There was a problem hiding this comment.
For the code parts of the course, we use https://huggingface.co/agents-course/notebooks/ as source. I've pushed the changes there
Member
|
Thanks!! |
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.
Fixes #612
Problem
The Dummy Agent Library notebook code uses
os.environ.get("HF_TOKEN")to read the token, which silently returnsNonein Google Colab. In Colab, secrets are stored in a separate keystore and must be accessed viagoogle.colab.userdata.get(), notos.environ. This causes subsequent API calls to fail — but since the token assignment doesn't raise an error, users have no way to know what went wrong.Solution
Updated the token-loading snippet in
dummy-agent-library.mdxto:google.colab.userdata.get('HF_TOKEN')first (Colab environment)os.environ.get("HF_TOKEN")in all other environments (local, Jupyter, etc.)token=HF_TOKENtoInferenceClientso the token is actually usedTesting
Documentation-only change to the code snippet shown in the course page. Logic is straightforward environment detection with a graceful fallback.