Skip to content

Add Hermes Workspace compatibility endpoints to api_server - #8772

Open
zjw200056061816-collab wants to merge 1 commit into
NousResearch:mainfrom
zjw200056061816-collab:workspace-api-compat
Open

Add Hermes Workspace compatibility endpoints to api_server#8772
zjw200056061816-collab wants to merge 1 commit into
NousResearch:mainfrom
zjw200056061816-collab:workspace-api-compat

Conversation

@zjw200056061816-collab

Copy link
Copy Markdown

What

This extends gateway/platforms/api_server.py with the Hermes-native /api/* endpoints Hermes Workspace expects for enhanced mode.

Added:

  • session APIs
    • GET/POST /api/sessions
    • GET /api/sessions/search
    • GET/PATCH/DELETE /api/sessions/{session_id}
    • GET /api/sessions/{session_id}/messages
    • POST /api/sessions/{session_id}/fork
    • POST /api/sessions/{session_id}/chat
    • POST /api/sessions/{session_id}/chat/stream
  • skills APIs
    • GET /api/skills
    • GET /api/skills/categories
    • GET /api/skills/{name}
  • memory API
    • GET /api/memory
  • config APIs
    • GET /api/config
    • PATCH /api/config

Also included:

  • session/message serialization helpers
  • model override support for API-server-created agents
  • SSE event translation for session chat streams

Why

Hermes Workspace can already use upstream in portable mode through:

  • /health
  • /v1/models
  • /v1/chat/completions

But it needs additional Hermes-native APIs to unlock enhanced mode features like:

  • persistent sessions
  • enhanced session chat
  • skills browsing
  • memory inspection
  • config editing

This PR adds those APIs by reusing existing upstream components (SessionDB, tools.skills_tool, hermes_cli.config, and AIAgent streaming callbacks) instead of introducing a parallel persistence layer.

Validation

Validated against a live Hermes deployment:

  • /api/sessions works
  • /api/skills works
  • /api/memory works
  • /api/config works

Hermes Workspace capability probing switched from portable mode to enhanced mode:

  • sessions: true
  • enhancedChat: true
  • skills: true
  • memory: true
  • config: true
  • jobs: true

Notes

  • /api/memory is intentionally lightweight in this pass
  • this PR does not add skill install/uninstall APIs
  • existing API_SERVER_KEY auth behavior is unchanged

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Appears to overlap with #7866 and #6334 — both add workspace API endpoints to api_server. Please check if this supersedes or conflicts with those PRs.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the Workspace compatibility work. The session-control goal has since landed, but this patch needs a focused salvage rather than a direct merge.

Problems

  • gateway/platforms/api_server.py:1349 persists caller-provided session IDs without the traversal/control-character/length validation current main applies at gateway/platforms/api_server.py:1737-1743; this boundary was hardened in ea1372d2.
  • _serialize_session at gateway/platforms/api_server.py:470-474 returns full session rows, including system_prompt and parsed model_config. Current main intentionally uses a safe allowlist at gateway/platforms/api_server.py:1639-1654.
  • PATCH /api/config at gateway/platforms/api_server.py:1835-1844 mutates arbitrary config and .env entries, while current /v1/capabilities explicitly advertises admin_config_rw: false (gateway/platforms/api_server.py:1502).
  • The PR changes only api_server.py; no regression tests accompany the new HTTP surface.

Suggested changes

  • Build any remaining Workspace-specific contract on the shipped session API (f7527b0fd) and current /v1/skills capability surface.
  • Preserve the current session-ID validation and response redaction, and split administrative config/environment changes into an explicitly approved design with E2E coverage.

Automated hermes-sweeper review.

except Exception:
body = {}

session_id = str(body.get("id") or body.get("session_id") or uuid.uuid4()).strip()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This accepts arbitrary session IDs before persisting them. Current main rejects traversal/control-character/oversized IDs at this API boundary (gateway/platforms/api_server.py:1737-1743), added by security fix ea1372d2; carry that validation here before create_session.

except Exception:
return raw

def _serialize_session(self, session: Dict[str, Any]) -> Dict[str, Any]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Returning a copied full SessionDB row exposes fields that the current API deliberately withholds, including system_prompt and model_config. Reuse a safe-field serializer like current main's _session_response instead of returning the full record.


if config_patch:
current = read_raw_config()
self._deep_merge(current, config_patch)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This turns the API-server bearer credential into unrestricted config and .env administration. Current main intentionally advertises admin_config_rw: false; please split this behind an explicitly designed administrative contract rather than including it in the session compatibility surface.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants