feat: agentic server Phase 1 — context.agent injection + standalone LLM gateway#100
Closed
pyramation wants to merge 3 commits into
Closed
feat: agentic server Phase 1 — context.agent injection + standalone LLM gateway#100pyramation wants to merge 3 commits into
pyramation wants to merge 3 commits into
Conversation
…ervice - Add AgentContext type to fn-types (inference, embed, databaseId, entityId) - Implement createAgentContext in fn-runtime/src/agent.ts - Wire agent context into buildContext (identity headers set server-side) - Create @constructive-io/agentic-server package (OpenAI-compatible proxy) - Multi-provider support (OpenAI, Ollama, Anthropic) - Header security: strips X-Database-Id from external requests - Health check endpoint at /healthz - Add agentic-server to docker-compose.yml (port 3003) - Add AGENTIC_SERVER_URL to make dev-fn - Add Python agent context (templates/python/agent.py) - Update example handlers to document context.agent usage - 7 new integration tests for AgentContext (TDD) - Fix runtime.test.ts to match actual example handler output - Update mock-context.ts with agent field Refs: constructive-planning#1060
🤖 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:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The beforeAll hooks in E2E tests timed out at 30s when the K8s PostgreSQL pod wasn't fully ready. This is a known flaky pattern across multiple branches (main run 26556238326, lucas/node-sql run 26404477809). Changes: - getTestConnections(): retry up to 10 times with 3s intervals - Pool: add connectionTimeoutMillis: 5000 (fail fast per attempt) - All E2E beforeAll hooks: increase timeout to 90s
This was referenced Jun 14, 2026
|
Superseded — already merged into develop via #104 |
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
context.agenttoFunctionContext— every cloud function (Node.js and Python) now has a fully typed, tenant-isolated LLM inference client injected automatically. Also creates@constructive-io/agentic-serveras a standalone OpenAI-compatible proxy that spins up withdocker compose upon port 3003.Three-layer architecture:
context.agent.inference({ messages, model })/context.agent.embed(input)in fn-runtimepackages/agentic-server/proxies to any LLM provider (OpenAI, Ollama, Anthropic)X-Database-Id/X-Entity-Id/X-Actor-Idset server-side from job context (unforgeable); external requests have identity headers strippedKey interfaces:
fn-runtime wiring:
buildContext()callscreateAgentContext(env.AGENTIC_SERVER_URL, { databaseId, entityId, actorId }). WhenAGENTIC_SERVER_URLis unset, methods throw with a descriptive error;databaseId/entityIdare still readable.Agentic server: OpenAI-compatible proxy (
/v1/chat/completions,/v1/embeddings,/healthz) with per-provider request/response transformation (Ollama ↔ OpenAI format normalization). Header middleware stripsX-Database-Idfrom external requests (only trustsX-Internal-Service: fn-runtime).Docker Compose:
agentic-serverservice added (port 3003),LLM_PROVIDER_URL/LLM_PROVIDER_TYPE/LLM_PROVIDER_API_KEYenv vars.make dev-fnauto-setsAGENTIC_SERVER_URL=http://localhost:3003.Python template:
templates/python/agent.py—AgentContextdataclass withfrom_request(request),inference(),embed(). Injected into handler asagentkwarg.Tests: 7 new integration tests (TDD) covering inference routing, embed routing, header forwarding, stub behavior, and security.
E2E fix: Added connection retry logic (
getTestConnections()retries 10× with 3s intervals) and 90sbeforeAlltimeout to all E2E tests. This fixes a pre-existing flaky timeout when the K8s PostgreSQL pod isn't ready within 30s (observed on main run 26556238326 and other branches).Refs: constructive-planning#1060
Link to Devin session: https://app.devin.ai/sessions/b2291a8e333e445aa125a2efd1996206
Requested by: @pyramation