mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: wire agent/account/user params through _VikingClient
- Fix copy-paste bug: `self._agent = user` → `self._agent = agent` with new `agent` parameter in `_VikingClient.__init__` - Read account/user/agent env vars in `initialize()` and pass them to all 4 `_VikingClient` instantiations so identity headers are consistently applied across health check, prefetch, sync, and memory write paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0c30385be2
commit
5082a9f66c
1 changed files with 21 additions and 6 deletions
|
|
@ -81,12 +81,12 @@ class _VikingClient:
|
||||||
"""Thin HTTP client for the OpenViking REST API."""
|
"""Thin HTTP client for the OpenViking REST API."""
|
||||||
|
|
||||||
def __init__(self, endpoint: str, api_key: str = "",
|
def __init__(self, endpoint: str, api_key: str = "",
|
||||||
account: str = "", user: str = ""):
|
account: str = "", user: str = "", agent: str = ""):
|
||||||
self._endpoint = endpoint.rstrip("/")
|
self._endpoint = endpoint.rstrip("/")
|
||||||
self._api_key = api_key
|
self._api_key = api_key
|
||||||
self._account = account or os.environ.get("OPENVIKING_ACCOUNT", "default")
|
self._account = account or os.environ.get("OPENVIKING_ACCOUNT", "default")
|
||||||
self._user = user or os.environ.get("OPENVIKING_USER", "default")
|
self._user = user or os.environ.get("OPENVIKING_USER", "default")
|
||||||
self._agent = user or os.environ.get("OPENVIKING_AGENT", "hermes")
|
self._agent = agent or os.environ.get("OPENVIKING_AGENT", "hermes")
|
||||||
self._httpx = _get_httpx()
|
self._httpx = _get_httpx()
|
||||||
if self._httpx is None:
|
if self._httpx is None:
|
||||||
raise ImportError("httpx is required for OpenViking: pip install httpx")
|
raise ImportError("httpx is required for OpenViking: pip install httpx")
|
||||||
|
|
@ -312,11 +312,17 @@ class OpenVikingMemoryProvider(MemoryProvider):
|
||||||
def initialize(self, session_id: str, **kwargs) -> None:
|
def initialize(self, session_id: str, **kwargs) -> None:
|
||||||
self._endpoint = os.environ.get("OPENVIKING_ENDPOINT", _DEFAULT_ENDPOINT)
|
self._endpoint = os.environ.get("OPENVIKING_ENDPOINT", _DEFAULT_ENDPOINT)
|
||||||
self._api_key = os.environ.get("OPENVIKING_API_KEY", "")
|
self._api_key = os.environ.get("OPENVIKING_API_KEY", "")
|
||||||
|
self._account = os.environ.get("OPENVIKING_ACCOUNT", "default")
|
||||||
|
self._user = os.environ.get("OPENVIKING_USER", "default")
|
||||||
|
self._agent = os.environ.get("OPENVIKING_AGENT", "hermes")
|
||||||
self._session_id = session_id
|
self._session_id = session_id
|
||||||
self._turn_count = 0
|
self._turn_count = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._client = _VikingClient(self._endpoint, self._api_key)
|
self._client = _VikingClient(
|
||||||
|
self._endpoint, self._api_key,
|
||||||
|
account=self._account, user=self._user, agent=self._agent,
|
||||||
|
)
|
||||||
if not self._client.health():
|
if not self._client.health():
|
||||||
logger.warning("OpenViking server at %s is not reachable", self._endpoint)
|
logger.warning("OpenViking server at %s is not reachable", self._endpoint)
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
@ -372,7 +378,10 @@ class OpenVikingMemoryProvider(MemoryProvider):
|
||||||
|
|
||||||
def _run():
|
def _run():
|
||||||
try:
|
try:
|
||||||
client = _VikingClient(self._endpoint, self._api_key)
|
client = _VikingClient(
|
||||||
|
self._endpoint, self._api_key,
|
||||||
|
account=self._account, user=self._user, agent=self._agent,
|
||||||
|
)
|
||||||
resp = client.post("/api/v1/search/find", {
|
resp = client.post("/api/v1/search/find", {
|
||||||
"query": query,
|
"query": query,
|
||||||
"top_k": 5,
|
"top_k": 5,
|
||||||
|
|
@ -407,7 +416,10 @@ class OpenVikingMemoryProvider(MemoryProvider):
|
||||||
|
|
||||||
def _sync():
|
def _sync():
|
||||||
try:
|
try:
|
||||||
client = _VikingClient(self._endpoint, self._api_key)
|
client = _VikingClient(
|
||||||
|
self._endpoint, self._api_key,
|
||||||
|
account=self._account, user=self._user, agent=self._agent,
|
||||||
|
)
|
||||||
sid = self._session_id
|
sid = self._session_id
|
||||||
|
|
||||||
# Add user message
|
# Add user message
|
||||||
|
|
@ -463,7 +475,10 @@ class OpenVikingMemoryProvider(MemoryProvider):
|
||||||
|
|
||||||
def _write():
|
def _write():
|
||||||
try:
|
try:
|
||||||
client = _VikingClient(self._endpoint, self._api_key)
|
client = _VikingClient(
|
||||||
|
self._endpoint, self._api_key,
|
||||||
|
account=self._account, user=self._user, agent=self._agent,
|
||||||
|
)
|
||||||
# Add as a user message with memory context so the commit
|
# Add as a user message with memory context so the commit
|
||||||
# picks it up as an explicit memory during extraction
|
# picks it up as an explicit memory during extraction
|
||||||
client.post(f"/api/v1/sessions/{self._session_id}/messages", {
|
client.post(f"/api/v1/sessions/{self._session_id}/messages", {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue