Skip to content

feat(ai): agent context policy (0028) + structured output (0030) + Swagger /docs base-path fix - #97

Merged
gustavobertoi merged 4 commits into
mainfrom
feat/agent-leaf-and-docs-consolidated
Jun 4, 2026
Merged

gustavobertoi merged 4 commits into
mainfrom
feat/agent-leaf-and-docs-consolidated

Conversation

@gustavobertoi

Copy link
Copy Markdown
Collaborator

One consolidated PR to main. The leaf agent PRs got merged into their stacked feature
branches instead of main, so this re-lands the missing work in a single, flat PR. (#93 — LLM
usage metrics — already reached main; not included here.) Supersedes the open #96.

Included

  • ADR-0028 — agent context-assembly policy: ai/agent gains maxContextTokens +
    contextStrategy (drop-oldest default | summarize); the running transcript is bounded before
    each completion, preserving the system turns + first task + most-recent turns. Opt-in / backward
    compatible.
  • ADR-0030 — structured output: opt-in outputSchema on ai/chat & ai/agent returns a
    validated object via a forced respond tool (universal across providers), with one repair
    retry. Backward compatible.
  • Swagger /docs behind a path prefix: the /docs redirect honors X-Forwarded-Prefix →
    falls back to a new SERVER_BASE_PATH (e.g. /fuse); the UI loads its spec relatively so it
    resolves under the prefix. Fixes docs 404 when hosted at api.example.com/fuse.

ADRs 0028 & 0030 flip Proposed → Accepted with shipped notes.

Verify

make lint 0 · make build ok · make test 710 pass.

🤖 Generated with Claude Code

gustavobertoi and others added 4 commits June 4, 2026 00:41
ai/agent gains optional maxContextTokens (approximate budget) + contextStrategy
(drop-oldest default | summarize). Before each completion the running transcript
is bounded by trimContext: it preserves the leading system turns + the first
user task and the most recent turns, dropping the oldest middle turns;
'summarize' replaces them with one LLM-generated summary turn (opt-in extra call,
recorded as a steps entry). Token estimate is a coarse ~4-chars/token heuristic,
centralized for a future tokenizer. Absent budget = unchanged behavior.

Persisted cross-run session store (Option B) and vector/RAG (Option C) deferred.
ADR-0028 Proposed -> Accepted (Option A shipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…spond (ADR-0030)

Opt-in: an outputSchema input (list of {name,type,required,description}) makes the
node return a validated object instead of free-form text. A single forced
"respond" tool carries the schema (ParameterSchemaToJSONSchema) with
ToolChoice=required; the tool-call args are parsed and validated, with one
bounded repair retry. Works on every provider (all support tool calling). The
agent runs its normal loop then coerces the final answer. Absent outputSchema =
unchanged.

Provider-native response_format (Option B) deferred. ADR-0030 Proposed -> Accepted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…h prefix

When FUSE is hosted under a sub-path (e.g. api.example.com/fuse), the /docs
redirect used an absolute /docs/index.html, so the browser dropped the /fuse
prefix and 404'd. Now the redirect honors the proxy's X-Forwarded-Prefix header,
falling back to a new SERVER_BASE_PATH config; and the Swagger UI loads its spec
via a relative URL (doc.json) so it resolves under the prefix automatically (or an
absolute base-path URL when SERVER_BASE_PATH is set). Root hosting is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gustavobertoi
gustavobertoi merged commit 3617831 into main Jun 4, 2026
5 checks passed
@gustavobertoi
gustavobertoi deleted the feat/agent-leaf-and-docs-consolidated branch June 4, 2026 06:19

This branch was previously deployed

1 inactive deployment
prod — c5d16421 Deployed Jun 4, 2026 by gustavobertoi via pr-image #323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant