Add OpenRouter app attribution headers to skills_guard and trajectory_compressor
These two files were creating bare OpenAI clients pointing at OpenRouter without the HTTP-Referer / X-OpenRouter-Title / X-OpenRouter-Categories headers that the rest of the codebase sends for app attribution. - skills_guard.py: LLM audit client (always OpenRouter) - trajectory_compressor.py: sync + async summarization clients (guarded with 'openrouter' in base_url check since the endpoint is user-configurable)
This commit is contained in:
@@ -946,6 +946,11 @@ def llm_audit_skill(skill_path: Path, static_result: ScanResult,
|
||||
client = OpenAI(
|
||||
base_url=OPENROUTER_BASE_URL,
|
||||
api_key=api_key,
|
||||
default_headers={
|
||||
"HTTP-Referer": "https://github.com/NousResearch/hermes-agent",
|
||||
"X-OpenRouter-Title": "Hermes Agent",
|
||||
"X-OpenRouter-Categories": "productivity,cli-agent",
|
||||
},
|
||||
)
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
|
||||
@@ -351,16 +351,27 @@ class TrajectoryCompressor:
|
||||
|
||||
from openai import OpenAI, AsyncOpenAI
|
||||
|
||||
# OpenRouter app attribution headers (only for OpenRouter endpoints)
|
||||
extra = {}
|
||||
if "openrouter" in self.config.base_url.lower():
|
||||
extra["default_headers"] = {
|
||||
"HTTP-Referer": "https://github.com/NousResearch/hermes-agent",
|
||||
"X-OpenRouter-Title": "Hermes Agent",
|
||||
"X-OpenRouter-Categories": "productivity,cli-agent",
|
||||
}
|
||||
|
||||
# Sync client (for backwards compatibility)
|
||||
self.client = OpenAI(
|
||||
api_key=api_key,
|
||||
base_url=self.config.base_url
|
||||
base_url=self.config.base_url,
|
||||
**extra,
|
||||
)
|
||||
|
||||
# Async client for parallel processing
|
||||
self.async_client = AsyncOpenAI(
|
||||
api_key=api_key,
|
||||
base_url=self.config.base_url
|
||||
base_url=self.config.base_url,
|
||||
**extra,
|
||||
)
|
||||
|
||||
print(f"✅ Initialized OpenRouter client: {self.config.summarization_model}")
|
||||
|
||||
Reference in New Issue
Block a user