Skip to content

feat(api,frontend): build kit served as the __ag__build_kit static workflow - #5130

Merged
mmabrouk merged 1 commit into
big-agentsfrom
feat/build-kit-static-workflow
Jul 7, 2026
Merged

feat(api,frontend): build kit served as the __ag__build_kit static workflow#5130
mmabrouk merged 1 commit into
big-agentsfrom
feat/build-kit-static-workflow

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Jul 7, 2026

Copy link
Copy Markdown
Member

Context

Agents created through the template-builder and playground-native flows showed no build kit in Advanced and ran without its tools, even after committing. The kit was delivered solely as a rider on GET /simple/applications/{id}, keyed by a workflow_id that ephemeral drafts don't have. Design (reviewed by codex at xhigh, then implemented per the folded plan): the kit becomes the reserved static workflow __ag__build_kit — a constant agent configuration in the StaticWorkflowCatalog, same namespace as the other __ag__* platform constants. Stacked on the design-docs PR #5124.

Changes

Backend:

  • core/workflows/build_kit.py (new): the kit's content builder — forced builtins, the 13 DEFAULT_BUILD_KIT_OPS, the request-connection tool embed, the build-an-agent skill embed, sandbox permissions. Core owns the content; apis/fastapi/applications/overlay.py shrinks to a thin back-compat adapter (core never imports the API layer).
  • static_catalog.py: the __ag__build_kit entry with explicit per-entry metadata (kind, embeddable) on every catalog entry, lazy revision factories, and an is_embeddable accessor. The old "non-skill means tool" inference is gone; only request_connection is a tool embed, so the kit cannot embed itself.
  • Policy: __ag__build_kit is retrievable but not embeddable/committable — enforced with a typed error at the embed resolver AND the commit path (commits don't resolve embeds, so resolver-only enforcement wouldn't hold).

Frontend:

  • agentBuildKitOverlayAtom: fetches the kit once per project by resolving the slug through the existing workflow-retrieve path; staleTime: Infinity.
  • workflowAgentTemplateOverlayAtomFamily: gates on the target entity being agent-typed (flags on committed revisions, flags on ephemeral local-* drafts, builtin-URI fallback) and serves the slug-fetched kit; the legacy per-application chain is retained as a deployment-skew fallback (used only when the slug fetch definitively fails and a workflow_id exists).
  • Fixes a pre-existing broken import in fetchSimpleApplication (used but never imported since merge 9cb1586329) — the fallback needs it to compile.

Scope / risk

The per-application additional_context rider is untouched this release (retirement is the planned follow-up once the FE migration has soaked). useBuildKit and the rendering are unchanged — only the data source moved. The kit content is byte-equivalent to the old overlay output (pinned by test). Risk to watch: any consumer that enumerated non-skill catalog entries as tools now needs the explicit allowlist (all in-repo consumers updated; the tests would catch a regression).

Tests / verification

  • 1250 api unit tests green, including 7 new pins: positive tool-embed allowlist, does-not-embed-itself, slug-retrieve content equivalence, embed rejection at resolve AND commit.
  • @agenta/entities: 11 new tests (slug fetch shape, boundary validation, ephemeral/committed/non-agent gating, no-session, fallback on error and on null); lint, types, build green. Two pre-existing failing test files (retrieveWorkflowRevision.test.ts, trace-migration-api.test.ts, real-HTTP tests) unrelated and unchanged.
  • Live API: slug retrieve returns the full 16-tool kit; committing a config embedding __ag__build_kit returns the typed 400.
  • Browser QA on the dev stack: fresh AND committed agents render the full kit in Advanced; the network log shows the __ag__build_kit retrieve (proving the new path, not the fallback).

How to QA

Prerequisites: any dev stack on this branch (api restart needed if the container predates the change — the bind-mount reload misses new modules).

Steps:

  1. Create an agent from a template, open the playground config panel → Advanced → Playground build kit.
  2. Expected: 13 platform tools, Request connection, the build-an-agent skill, sandbox permissions — before and after commit.
  3. POST /api/workflows/revisions/retrieve with {"workflow_ref": {"slug": "__ag__build_kit"}} → the kit revision.
  4. Commit a config whose skills embed __ag__build_kit → 400 "retrievable but cannot be embedded".

Automated tests: cd api && uv run --no-sync python -m pytest oss/tests/pytest/unit/applications/ oss/tests/pytest/unit/workflows/ -q and cd web && pnpm --filter @agenta/entities test.

Edge cases: a non-agent workflow (prompt/evaluator) must show no kit; an old cached frontend keeps working via the untouched rider.

https://claude.ai/code/session_01N2djTMgXnpk84EqtugHDJB

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 7, 2026
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 7, 2026 4:13pm

Request Review

@dosubot dosubot Bot added the enhancement New feature or request label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces a reserved "build kit" static workflow with a dedicated core overlay builder, blocks embedding of non-embeddable static workflows in resolution/commit paths via a new exception and service checks, and adds frontend logic to fetch and consume the build-kit overlay atom with fallback to per-application context.

Changes

Backend: build kit overlay and embed protection

Layer / File(s) Summary
Build kit module and overlay delegation
api/oss/src/core/workflows/build_kit.py, api/oss/src/apis/fastapi/applications/overlay.py, docs/design/agent-workflows/documentation/tools.md
New module defines build-kit metadata, tool/skill embed helpers, and build_agent_template_overlay(); the API overlay module now delegates to it and re-exports DEFAULT_BUILD_KIT_OPS; docs updated to reflect the new location.
Static catalog build-kit entry
api/oss/src/core/workflows/static_catalog.py, api/oss/src/core/workflows/interfaces.py
Adds callable revision declarations, a non-embeddable build-kit catalog entry, and an is_embeddable() implementation resolving ids to slugs; interface adds the abstract is_embeddable contract.
Non-embeddable exception and resolver rejection
api/oss/src/core/embeds/exceptions.py, api/oss/src/core/embeds/utils.py, api/oss/src/apis/fastapi/workflows/exceptions.py, api/oss/src/apis/fastapi/workflows/router.py
Adds NonEmbeddableWorkflowReferenceError/NonEmbeddableWorkflowReferenceException, wires exception translation into the workflow decorator and two router endpoints, and rejects non-embeddable static workflows during universal embed resolution.
Service-level embed validation
api/oss/src/core/workflows/service.py
create_workflow_revision and commit_workflow_revision now validate embedded references and raise NonEmbeddableWorkflowReferenceError for non-embeddable static workflow slugs before persisting.
Tests
api/oss/tests/pytest/unit/applications/test_build_kit_overlay.py, api/oss/tests/pytest/unit/workflows/test_static_catalog.py
Tests validate overlay parity, allowlisted embeds, and rejection of build-kit embeds during resolution/commit without DB calls.

Frontend: agent build-kit overlay consumption

Layer / File(s) Summary
fetchAgentBuildKitOverlay client
web/packages/agenta-entities/src/workflow/api/api.ts, .../api/index.ts, tests/unit/agent-build-kit-overlay-api.test.ts
Adds a reserved slug constant, Zod schema/type, and fetchAgentBuildKitOverlay() that retrieves and validates the reserved workflow revision overlay; exported via the API barrel and covered by unit tests.
Store atom integration
web/packages/agenta-entities/src/workflow/state/store.ts, tests/unit/agent-build-kit-overlay-atom.test.ts
Adds agentBuildKitOverlayAtom and reworks workflowAgentTemplateOverlayAtomFamily to prefer the slug-fetched overlay with fallback to per-application additional_context, covered by unit tests for multiple scenarios.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client as Frontend Atom
  participant API as fetchAgentBuildKitOverlay
  participant WorkflowsService
  participant StaticCatalog

  Client->>API: fetchAgentBuildKitOverlay(projectId)
  API->>WorkflowsService: retrieveWorkflowRevision(BUILD_KIT_WORKFLOW_SLUG)
  WorkflowsService->>StaticCatalog: retrieve_revision(slug)
  StaticCatalog-->>WorkflowsService: build_agent_template_overlay() data
  WorkflowsService-->>API: revision.data.parameters.agent
  API-->>Client: validated AgentBuildKitOverlay or null
  Client->>Client: fallback to additional_context.playground_build_kit if null/error
Loading
sequenceDiagram
  participant Caller as create/commit_workflow_revision
  participant Service as WorkflowsService
  participant Catalog as StaticWorkflowCatalog
  participant Resolver as EmbedResolver

  Caller->>Service: submit revision data with embeds
  Service->>Service: _reject_non_embeddable_workflow_embeds(data)
  Service->>Catalog: is_embeddable(id, slug)
  Catalog-->>Service: embeddable=False for build-kit slug
  Service->>Service: raise NonEmbeddableWorkflowReferenceError
  Resolver->>Catalog: is_embeddable(entity.id, entity.slug)
  Catalog-->>Resolver: embeddable status
  Resolver-->>Caller: reject or return resolved embed
Loading

Possibly related PRs

  • Agenta-AI/agenta#5068: Both PRs change build-kit agent template overlay construction and DEFAULT_BUILD_KIT_OPS handling in applications/overlay.py.
  • Agenta-AI/agenta#5074: Both PRs modify the build-kit overlay's default ops/tools set in the FastAPI overlay layer.
  • Agenta-AI/agenta#4929: Both PRs implement the playground build kit agent-template overlay, overlapping with the refactor delegating overlay construction to core/workflows/build_kit.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: serving the build kit as a reserved static workflow across API and frontend.
Description check ✅ Passed The description is detailed and directly describes the build-kit static workflow migration and related frontend/backend changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/build-kit-static-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mmabrouk

mmabrouk commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

lgtm

@mmabrouk
mmabrouk changed the base branch from docs/build-kit-overlay-delivery to big-agents July 7, 2026 16:19
@mmabrouk
mmabrouk merged commit 9fa287a into big-agents Jul 7, 2026
21 of 24 checks passed
@mmabrouk
mmabrouk deleted the feat/build-kit-static-workflow branch July 7, 2026 16:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
api/oss/src/core/workflows/static_catalog.py (1)

246-258: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Callable revisions bypass the "fail fast" validation guarantee.

The docstring states this method should "Fail fast at construction if any entry is malformed," but callables (line 248-249) are now skipped entirely — no check that the eventual WorkflowRevision has data.uri, etc. A malformed lazy factory would only surface at first retrieve_revision() call, not at catalogue construction.

Consider invoking each callable once during validation (and catching/re-raising with a clear error) to preserve the fail-fast contract for future callable-based entries.

♻️ Proposed fix to validate callables eagerly
             for version, revision in versions.items():
-                if callable(revision):
-                    continue
+                if callable(revision):
+                    revision = revision()
                 if (
                     not isinstance(revision, WorkflowRevision)
                     or not revision.data
                     or not revision.data.uri
                 ):
                     raise ValueError(
                         f"Static workflow {slug!r} version {version!r} must be a "
                         f"WorkflowRevision with data.uri."
                     )
api/oss/tests/pytest/unit/workflows/test_static_catalog.py (1)

392-478: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for create_workflow_revision rejection.

Only resolve_workflow_revision and commit_workflow_revision are tested for build-kit embed rejection, but the PR states rejection is also enforced in create_workflow_revision. Consider adding a parallel test there to lock in that path too.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bf988c7-8eb1-430b-ac1f-4fe96b1d15ef

📥 Commits

Reviewing files that changed from the base of the PR and between 6fa5937 and 1f2c024.

📒 Files selected for processing (17)
  • api/oss/src/apis/fastapi/applications/overlay.py
  • api/oss/src/apis/fastapi/workflows/exceptions.py
  • api/oss/src/apis/fastapi/workflows/router.py
  • api/oss/src/core/embeds/exceptions.py
  • api/oss/src/core/embeds/utils.py
  • api/oss/src/core/workflows/build_kit.py
  • api/oss/src/core/workflows/interfaces.py
  • api/oss/src/core/workflows/service.py
  • api/oss/src/core/workflows/static_catalog.py
  • api/oss/tests/pytest/unit/applications/test_build_kit_overlay.py
  • api/oss/tests/pytest/unit/workflows/test_static_catalog.py
  • docs/design/agent-workflows/documentation/tools.md
  • web/packages/agenta-entities/src/workflow/api/api.ts
  • web/packages/agenta-entities/src/workflow/api/index.ts
  • web/packages/agenta-entities/src/workflow/state/store.ts
  • web/packages/agenta-entities/tests/unit/agent-build-kit-overlay-api.test.ts
  • web/packages/agenta-entities/tests/unit/agent-build-kit-overlay-atom.test.ts

Comment on lines +278 to +288
def _reject_non_embeddable_static_workflow(entity: Any) -> None:
catalog = getattr(workflows_service, "static_catalog", None)
if not catalog or not entity:
return
slug = getattr(entity, "slug", None) or getattr(
entity, "workflow_slug", None
)
entity_id = getattr(entity, "id", None)
if not catalog.is_embeddable(id=entity_id, slug=slug):
raise NonEmbeddableWorkflowReferenceError(slug or str(entity_id))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all call sites of create_universal_resolver and check whether workflows_service always carries a static_catalog
rg -n 'create_universal_resolver\(' -A 10 -B 5 --type=py
rg -n 'WorkflowsService\(' -A 10 --type=py

Repository: Agenta-AI/agenta

Length of output: 154


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate relevant files and call sites.
git ls-files | rg 'api/oss/src/core/(embeds/utils\.py|workflows|.*resolver.*|.*service.*)\.py$|api/oss/src/core/.+\.py$' || true

echo '--- create_universal_resolver call sites ---'
rg -n 'create_universal_resolver\(' api/oss/src -g '*.py' -A 6 -B 6 || true

echo '--- WorkflowsService definitions/usages ---'
rg -n 'class WorkflowsService|WorkflowsService\(' api/oss/src -g '*.py' -A 8 -B 8 || true

echo '--- static_catalog references ---'
rg -n 'static_catalog' api/oss/src -g '*.py' -A 4 -B 4 || true

echo '--- embed helper context ---'
sed -n '250,310p' api/oss/src/core/embeds/utils.py

Repository: Agenta-AI/agenta

Length of output: 25624


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- relevant files ---'
git ls-files api/oss/src/core | rg 'embeds/utils\.py|workflows|resolver|service' || true

echo '--- create_universal_resolver call sites ---'
rg -n 'create_universal_resolver\(' api/oss/src -g '*.py' -A 6 -B 6 || true

echo '--- WorkflowsService definitions/usages ---'
rg -n 'class WorkflowsService|WorkflowsService\(' api/oss/src -g '*.py' -A 8 -B 8 || true

echo '--- static_catalog references ---'
rg -n 'static_catalog' api/oss/src -g '*.py' -A 4 -B 4 || true

echo '--- embed helper context ---'
sed -n '270,300p' api/oss/src/core/embeds/utils.py

Repository: Agenta-AI/agenta

Length of output: 16731


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- helper call sites in embeds/utils.py ---'
rg -n '_reject_non_embeddable_static_workflow\(' api/oss/src/core/embeds/utils.py -A 4 -B 4 || true

echo '--- workflow non-embeddable slug guard context ---'
sed -n '1320,1365p' api/oss/src/core/workflows/service.py

echo '--- resolver workflow branch context ---'
sed -n '288,430p' api/oss/src/core/embeds/utils.py

Repository: Agenta-AI/agenta

Length of output: 10176


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- embeds service wiring ---'
sed -n '1,140p' api/oss/src/core/embeds/service.py

echo '--- all WorkflowsService instantiations with context ---'
rg -n 'WorkflowsService\(' api/oss/src -g '*.py' -A 4 -B 4 || true

echo '--- static_catalog provider wiring ---'
rg -n 'StaticWorkflowProvider|static_catalog=' api/oss/src -g '*.py' -A 4 -B 4 || true

Repository: Agenta-AI/agenta

Length of output: 11016


Resolver should short-circuit reserved build-kit slugs even without a catalog.

_reject_non_embeddable_static_workflow returns early when workflows_service.static_catalog is unset, and the default WorkflowsService wiring leaves that field unset. That lets the embed resolver accept build-kit and other reserved static workflows. Add the BUILD_KIT_WORKFLOW_SLUG fallback before the catalog check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant