Skip to content

feat: include User-Agent request context header on generateContent calls - #2

Merged
gabbyong merged 2 commits into
mainfrom
feat/user-agent-header
Oct 29, 2026
Merged

gabbyong merged 2 commits into
mainfrom
feat/user-agent-header

Conversation

@gabbyong

@gabbyong gabbyong commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Adds a static User-Agent header ('hermes-agent (gemini-image/0.1.0)') to outgoing generateContent requests for support and compatibility context without including any user or prompt metadata. Updates the generation unit test to assert the header is sent alongside x-goog-api-key.

Adds a static User-Agent header ('hermes-agent (gemini-image/0.1.0)') to outgoing generateContent requests for support and compatibility context without including any user or prompt metadata. Updates the generation unit test to assert the header is sent alongside x-goog-api-key.
@gabbyong
gabbyong requested a review from markmcd October 9, 2026 08:17

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds a User-Agent header to the Google AI Studio API requests, defining PLUGIN_VERSION and USER_AGENT constants in init.py. It also updates the test suite to assert that the User-Agent header is correctly set. There are no review comments, so no feedback is provided.

Comment thread __init__.py Outdated
BASE_URL = "https://generativelanguage.googleapis.com/v1beta"
DEFAULT_MODEL = "gemini-nano-banana-2.1"
PLUGIN_VERSION = "0.1.0"
USER_AGENT = f"hermes-agent (gemini-image/{PLUGIN_VERSION})"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this needs to be hermes-agent/{hermes_version} (gemini-image)

or if you have both versions available you can just put both strings in the UA like hermes-agents/{hermes_version} gemini-image/{plugin_version}

e.g. https://github.com/NousResearch/hermes-agent/blob/5f045f842a60184748dda30acb9fecbd961cc18b/agent/gemini_native_adapter.py#L850-L851

they picked up the hermes version like this too, if that works?

if possible, I prefer the multi-agent version so we can understand both separately.

Formats User-Agent as 'hermes-agent/<hermes_version> gemini-image/<plugin_version>' using get_version_info().base_version so both versions can be tracked separately. Updates the unit test to verify both HERMES_VERSION and PLUGIN_VERSION are present in the header.
@gabbyong
gabbyong merged commit e178d4f into main Oct 29, 2026
7 checks passed
@gabbyong
gabbyong deleted the feat/user-agent-header branch October 29, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants