feat: add agentic-server package — standalone Express LLM service#1214
Merged
Conversation
Express-only equivalent of graphile-llm: agent threads, chat streaming, billing metering, and inference logging. Uses @constructive-io/express-context for tenant-scoped database access. Endpoints: - POST /v1/threads — create conversation thread - POST /v1/threads/:id/messages — send message + stream response (SSE) - POST /v1/orgs/:entity_id/threads — entity-scoped thread creation - POST /v1/orgs/:entity_id/threads/:id/messages — entity-scoped messaging - POST /v1/embed — generate embeddings Features: - OllamaAdapter for chat (streaming + batch) and embeddings - Automatic billing quota check + usage recording - Inference logging (token counts, latency, model) - TTL-based discovery caching (no graphile-cache dependency) - OpenAI-compatible SSE streaming format
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
agentic-server— the Express-only equivalent ofgraphile-llm. This is a standalone Express router that provides agent threads, chat streaming, billing metering, and inference logging without needing PostGraphile or any Graphile dependencies.Uses
@constructive-io/express-contextfor tenant-scoped database access (the whole reason we built express-context).Endpoints:
/v1/threads/v1/threads/:thread_id/messages/v1/orgs/:entity_id/threads/v1/orgs/:entity_id/threads/:thread_id/messages/v1/embedArchitecture:
Dependencies (minimal):
@constructive-io/express-context— tenant context (domain resolution, JWT, pgSettings, withPgClient)@agentic-kit/ollama— LLM provider calls (chat + embeddings)express(peer dep)pg,pg-cache,@pgpmjs/logger— database connectivity and loggingNo graphile-anything. The few SQL queries for agent/billing discovery live inside the package with a simple TTL cache (~45 lines).
Review & Testing Checklist for Human
createAgenticRouter()at the top ofserver.tsto confirm no conflicts)check_quota/record_usageSQL matches what the billing module actually exposes (function signatures)Notes
pnpm build), 8 unit tests pass (pnpm test)packages/*)graphql/server/src/middleware/llm-api.tsinto a standalone package, but does NOT remove the originalllm-api.tsyet — that can happen once this package is verified in productionagentic-server(no scope) per user requestLink to Devin session: https://app.devin.ai/sessions/2b5a29d83d3f478e8d3d972653b4879c
Requested by: @pyramation