The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(anthropic): OAuth slug rewrite skips paths, repo slugs and mailboxes too
kshitijk4poor75b62813942e
diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.pyindex efc88ca2064..9347acc4667 100644--- a/agent/anthropic_adapter.py+++ b/agent/anthropic_adapter.py@@ -470,9 +470,11 @@ def _oauth_wire_namer(anthropic_tools: List[Dict[str, Any]]):_OAUTH_SYSTEM_REPLACEMENTS = (("Hermes Agent", "Claude Code"), ("Hermes agent", "Claude Code"), ("Nous Research", "Anthropic"),)-# The slug is rewritten only as a standalone word: inside the docs host it is an address the-# model will dereference, and ``claude-code.nousresearch.com`` does not resolve (#48860).-_OAUTH_SLUG_PATTERN = re.compile(r"\bhermes-agent\b(?!\.nousresearch\.com)")+# The slug is rewritten only as a standalone word. Joined to a host, path, repo or mailbox+# (``hermes-agent.nousresearch.com``, ``~/.hermes/hermes-agent/venv``,+# ``NousResearch/hermes-agent``) it is an address the model dereferences, and the rewritten+# form does not exist (#48860).+_OAUTH_SLUG_PATTERN = re.compile(r"(?<![\w./:@-])hermes-agent(?![\w./@-])")def _apply_claude_code_identity(system, anthropic_tools, anthropic_messages, to_wire):diff --git a/tests/agent/test_anthropic_adapter.py b/tests/agent/test_anthropic_adapter.pyindex 53d185af156..f0ef4abe0f8 100644--- a/tests/agent/test_anthropic_adapter.py+++ b/tests/agent/test_anthropic_adapter.py@@ -1907,7 +1907,9 @@ def test_oauth_system_prompt_sanitizer_preserves_docs_url():"role": "system","content": ("Hermes Agent by Nous Research uses hermes-agent skills. "- "Docs: https://hermes-agent.nousresearch.com/docs"+ "Docs: https://hermes-agent.nousresearch.com/docs ; "+ "interpreter ~/.hermes/hermes-agent/venv/bin/python ; "+ "source github.com/NousResearch/hermes-agent"),},{"role": "user", "content": "Hi"},@@ -1921,4 +1923,8 @@ def test_oauth_system_prompt_sanitizer_preserves_docs_url():system_text = "\n".join(block["text"] for block in kwargs["system"])assert "Claude Code by Anthropic uses claude-code skills." in system_textassert "https://hermes-agent.nousresearch.com/docs" in system_text- assert "claude-code.nousresearch.com" not in system_text+ # Paths and repo slugs are addresses too: a subagent told to run+ # ``~/.hermes/claude-code/venv/bin/python`` fails on a file that does not exist.+ assert "~/.hermes/hermes-agent/venv/bin/python" in system_text+ assert "github.com/NousResearch/hermes-agent" in system_text+ assert "claude-code" not in system_text.replace("claude-code skills", "")