Skip to content

[AGE-4067] feat(agents): Inject custom secrets into agent runs - #6583

Open
mmabrouk wants to merge 8 commits into
release/v0.115.1from
feat/agent-custom-secrets-v1
Open

[AGE-4067] feat(agents): Inject custom secrets into agent runs#6583
mmabrouk wants to merge 8 commits into
release/v0.115.1from
feat/agent-custom-secrets-v1

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member

Context

Agenta can store custom secrets, but an agent cannot yet use them or ask a user to attach one during a conversation. This implements V1 from #6565 and targets release/v0.115.1. It includes the shared platform-instruction dependency required by secret guidance.

Changes

Users can attach a text secret in the agent's Advanced drawer or complete an agent's request_secret card. Both use the same attachment drawer and existing vault form. The form exposes an optional default environment variable directly below Value; an attachment can override it without changing the vault default. There are no service templates.

For example, a vault entry with default DEPLOY_TOKEN can be attached as STAGING_TOKEN. The agent revision stores only its secret slug and environment name. The SDK resolves the value for each run, and the runner injects it using its existing environment and credential lifecycle. Rotation and removal take effect on the next run while preserving the conversation and files.

Card completion saves the binding, adopts the returned revision, settles a reference-only tool result, and resumes the same conversation. An attachment failure retains the saved vault entry for retry. Resume transport failures retain their error callout through transcript refresh and offer the existing guarded turn retry; a repeated secret request can Continue with the saved binding. Shared guidance explains requesting and consuming attached variables without reading environment values into the prompt. Host-restricted delivery remains milestone two.

The native components and their states are in the existing Storybook organization. The original designer-review URL remains valid.

How to review

Start with the vault metadata and workflow permission changes, then the SDK resolver and runner lifecycle. Review the shared entity commit action and attachment components before the desktop and mobile hosts. The release-gate cell and browser checklist cover future regressions.

Tests

  • API tests cover write-only responses, credential-binding permissions, and static tool resolution through the API and SDK.
  • SDK and runner tests cover validation, collisions, reference resolution, instruction delivery, wire contracts, rotation, and removal.
  • Frontend tests cover binding commit conflicts and lost responses, metadata defaults and clearing, tool embedding, and adoption before automatic resume. Frontend lint and relevant type checks passed.
  • Live local Pi verified injection, rotation, removal, session/file continuity, and no plaintext in observed outputs. Real desktop QA verified request, cancel, create, attach, edit, remove, refresh, adoption, same-session resume, partial-save retry, dirty-draft blocking, failed-removal retry, and HTTP 503 resume recovery; a SHA-256 file confirmed the process received the dummy value.
  • Storybook rebuilt with 719 entries; native attachment and request states and the original designer story rendered in the browser.

Daytona live verification remains open: the disposable project has no usable OpenAI credential. The full three-harness, two-environment release matrix is not claimed as complete. Detailed results and remaining checks are in the QA record.

Demo

Create a requested secret in the real application

The same conversation resumes after attachment

What to QA

  • Settings and agent setup: create a text secret with an optional default, override its name on attachment, and confirm the saved vault default stays unchanged.
  • Advanced: attach, refresh, edit, and remove. Each operation adopts the new revision; removing a binding keeps the vault secret.
  • Conversation: request a secret, configure it, and confirm the same session resumes with the saved revision. Cancel should settle once without repeating the request.
  • Recovery: fail attachment after vault creation, then retry without creating another secret. Fail resume after attachment and retry using the saved revision.
  • Permissions: secret configuration fails closed without secret-edit permission; vault access alone does not permit an agent revision write.
  • Release: run matrix_s1_custom_secrets.py on Daytona with an authorized model credential, plus the remaining harness/environment combinations in the QA checklist.

@linear-code

linear-code Bot commented Sep 5, 2026

Copy link
Copy Markdown

AGE-4067

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 5, 2026 6:45pm UTC

Request Review

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📘 Docs preview

Status ✅ Ready
Preview https://pr-6583-agenta-docs-preview.mahmoud-637.workers.dev/docs
Inspect Actions run
Commit 31b389d8e438503abd1b4f486f6ff68e900ed498

This comment updates in place on every push.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 09d3baaa-3d78-4989-a16e-2a7a358b37f7

📥 Commits

Reviewing files that changed from the base of the PR and between b30df34 and 31b389d.

📒 Files selected for processing (3)
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts
  • web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added custom secret management for agents, including attaching, editing, removing, and creating text secrets as environment variables.
    • Added an in-chat secret request flow with setup, cancellation, retry, and resume support.
    • Added support for delivering configured secrets to local and Daytona sandboxes with validation and redaction.
    • Added suggested default environment-variable names and editable secret metadata.
    • Added permission checks for secret attachment and workflow changes.
  • Documentation

    • Added product design, QA guidance, recovery scenarios, and interactive Storybook prototypes for custom secrets.

Walkthrough

The change adds project-scoped custom-secret bindings across the API, SDK, runner, entities, UI, and chat flows. It adds request_secret, permission checks, revision adoption, runtime injection, redaction, lifecycle handling, release-gate coverage, design documentation, QA evidence, and Storybook prototypes.

Changes

Custom secrets and platform delivery

Layer / File(s) Summary
API contracts and workflow permissions
api/oss/src/core/secrets/*, api/oss/src/core/workflows/*, api/oss/src/apis/fastapi/workflows/router.py
Adds default environment metadata, the request_secret workflow, and edit_secret checks for credential-bearing revisions and forks.
SDK and runner delivery
sdks/python/agenta/sdk/agents/*, services/runner/src/engines/sandbox_agent/*, services/runner/src/environment/*
Adds credential schemas, resolution, wire transport, validation, environment injection, redaction, lifecycle fingerprints, and platform-instruction compatibility.
Revision and UI flows
web/packages/agenta-entities/*, web/packages/agenta-entity-ui/*, web/packages/agenta-chat/*, web/oss/*, web/mobile/*
Adds binding commits, attachment drawers, Advanced secret management, request docks, permission handling, revision adoption, and resume behavior.
Release validation and supporting artifacts
.agents/skills/agent-release-gate/*, docs/design/*, web/storybook/*
Adds the live release cell, path triggers, QA and design documentation, evidence fixtures, Storybook stories, and interactive prototypes.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟡 Moderate · up to 31b38

Custom-secret attachment and request-secret flows add runtime credential delivery and revision-resume behavior, but unresolved validation, interaction, and release-coverage issues could cause failed secret runs or degraded setup flows. These risks should be addressed before merge.

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant ChatHost
  participant SecretRequestDock
  participant CommitAgentCredentials
  participant WorkflowAPI
  Agent->>ChatHost: Emit request_secret interaction
  ChatHost->>SecretRequestDock: Render pending request
  SecretRequestDock->>CommitAgentCredentials: Submit secret binding
  CommitAgentCredentials->>WorkflowAPI: Commit workflow revision
  WorkflowAPI-->>CommitAgentCredentials: Return revision ID
  CommitAgentCredentials-->>SecretRequestDock: Adopt committed revision
  SecretRequestDock->>ChatHost: Send tool output
  ChatHost->>Agent: Resume conversation
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.13% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 103 functions across 52 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: injecting custom secrets into agent runs.
Description check ✅ Passed The description directly explains the custom-secret implementation, user flows, runtime behavior, tests, and remaining Daytona verification.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-custom-secrets-v1

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.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-6583.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-6583-89c11bb
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-09-05T18:55:43.763Z

@mmabrouk
mmabrouk changed the base branch from docs/agent-custom-secrets-plan to release/v0.115.1 September 5, 2026 18:19
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Website preview

Preview URL: https://pr-6583-agenta-website-preview.mahmoud-637.workers.dev

Built from b30df34b1cd6f253f41f3543c5af1b2f76c862fe. This comment updates in place on every push.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 14

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/design/agent-custom-secrets/qa-browser-evidence.md (1)

39-42: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Complete the documented QA cleanup.

The browser checklist requires deleting the unique test secret after validation, but this evidence records qa-advanced-knog6u and a retained dummy attachment. Remove the retained fixtures or document a verified disposable-project teardown before using this evidence as the release record.

🧹 Nitpick comments (1)
web/packages/agenta-entity-ui/src/secret/SecretForm/useSecretForm.ts (1)

143-144: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep this comment to one short line. As per coding guidelines: “Hard rule. At most ONE short line per comment.”

Proposed fix
-        // Keyed on the secret's identity, not its object identity: a re-created prop must
-        // not wipe what the user has typed while the form is open.
+        // Key on the secret ID to preserve active input through prop recreation.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: a0bc6f03-ce68-47e1-bd8e-07be37d8d4d9

📥 Commits

Reviewing files that changed from the base of the PR and between 4e5e172 and b30df34.

⛔ Files ignored due to path filters (6)
  • docs/design/agent-custom-secrets/assets/advanced-demo.png is excluded by !**/*.png
  • docs/design/agent-custom-secrets/assets/request-create-demo.png is excluded by !**/*.png
  • docs/design/agent-custom-secrets/assets/request-demo.png is excluded by !**/*.png
  • docs/design/agent-custom-secrets/assets/resume-demo.png is excluded by !**/*.png
  • docs/design/agent-custom-secrets/assets/retry-demo.png is excluded by !**/*.png
  • web/packages/agenta-api-client/src/generated/api/types/CustomSecretSettingsDto.ts is excluded by !**/generated/**
📒 Files selected for processing (117)
  • .agents/skills/agent-release-gate/resources/coverage.md
  • .agents/skills/agent-release-gate/resources/matrix_s1_custom_secrets.py
  • .agents/skills/agent-release-gate/resources/path_triggers.py
  • .agents/skills/agent-release-gate/resources/test_custom_secret_gate.py
  • api/oss/src/apis/fastapi/workflows/router.py
  • api/oss/src/core/secrets/dtos.py
  • api/oss/src/core/secrets/services.py
  • api/oss/src/core/workflows/static_catalog.py
  • api/oss/tests/pytest/unit/vault/test_write_only_routes.py
  • api/oss/tests/pytest/unit/workflows/test_sandbox_credential_permissions.py
  • api/oss/tests/pytest/unit/workflows/test_static_catalog.py
  • docs/design/agent-custom-secrets/README.md
  • docs/design/agent-custom-secrets/assets/advanced-recovery-evidence.json
  • docs/design/agent-custom-secrets/assets/browser-resume-evidence.json
  • docs/design/agent-custom-secrets/assets/retry-evidence.json
  • docs/design/agent-custom-secrets/context.md
  • docs/design/agent-custom-secrets/contracts.md
  • docs/design/agent-custom-secrets/plan.md
  • docs/design/agent-custom-secrets/qa-browser-checklist.md
  • docs/design/agent-custom-secrets/qa-browser-evidence.md
  • docs/design/agent-custom-secrets/qa.md
  • docs/design/agent-custom-secrets/research.md
  • docs/design/agent-custom-secrets/simplification.md
  • docs/design/agent-custom-secrets/status.md
  • docs/design/agent-platform-instructions/README.md
  • docs/design/agent-platform-instructions/context.md
  • docs/design/agent-platform-instructions/plan.md
  • docs/design/agent-platform-instructions/research.md
  • docs/design/agent-platform-instructions/status.md
  • docs/design/agent-workflows/documentation/protocol.md
  • sdks/python/agenta/sdk/agents/__init__.py
  • sdks/python/agenta/sdk/agents/adapters/agenta_builtins.py
  • sdks/python/agenta/sdk/agents/adapters/harnesses.py
  • sdks/python/agenta/sdk/agents/dtos.py
  • sdks/python/agenta/sdk/agents/handler.py
  • sdks/python/agenta/sdk/agents/platform/gateway.py
  • sdks/python/agenta/sdk/agents/platform/workflow.py
  • sdks/python/agenta/sdk/agents/platform_instructions.py
  • sdks/python/agenta/sdk/agents/sandbox_credentials.py
  • sdks/python/agenta/sdk/agents/utils/wire.py
  • sdks/python/agenta/sdk/agents/wire_models.py
  • sdks/python/agenta/sdk/utils/types.py
  • sdks/python/oss/tests/pytest/unit/agents/golden/run_request.codex.json
  • sdks/python/oss/tests/pytest/unit/agents/golden/run_request.gateway_connection.json
  • sdks/python/oss/tests/pytest/unit/agents/platform/test_gateway_connection_resolve.py
  • sdks/python/oss/tests/pytest/unit/agents/test_dtos_agent_template.py
  • sdks/python/oss/tests/pytest/unit/agents/test_harness_adapters.py
  • sdks/python/oss/tests/pytest/unit/agents/test_sandbox_credentials.py
  • sdks/python/oss/tests/pytest/unit/agents/test_wire_contract.py
  • services/runner/src/engines/sandbox_agent/harness-trace-port.ts
  • services/runner/src/engines/sandbox_agent/run-plan.ts
  • services/runner/src/engines/sandbox_agent/sandbox-credentials.ts
  • services/runner/src/engines/sandbox_agent/session-identity.ts
  • services/runner/src/environment/runtime-lifecycle.ts
  • services/runner/src/lifecycle/desired-state.ts
  • services/runner/src/protocol.ts
  • services/runner/src/redaction.ts
  • services/runner/tests/unit/lifecycle-desired-state.test.ts
  • services/runner/tests/unit/lifecycle-session-coordinator.test.ts
  • services/runner/tests/unit/sandbox-agent-run-plan.test.ts
  • services/runner/tests/unit/sandbox-credentials.test.ts
  • services/runner/tests/unit/session-pool.test.ts
  • services/runner/tests/unit/wire-contract.test.ts
  • web/.prettierignore
  • web/mobile/src/features/chat/ConfigPane.tsx
  • web/mobile/src/features/chat/DrillInBridgeProvider.tsx
  • web/mobile/src/features/chat/LiveConversation.tsx
  • web/mobile/src/features/chat/SessionWorkspace.tsx
  • web/mobile/src/features/context/useProjectPermission.ts
  • web/mobile/tests/unit/projectPermission.test.ts
  • web/oss/src/components/AgentChatSlice/AgentConversation.tsx
  • web/oss/src/components/AgentChatSlice/components/AgentComposerDock.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/oss/src/components/DrillInView/OSSdrillInUIProvider.tsx
  • web/packages/agenta-chat/src/clientTools/index.ts
  • web/packages/agenta-chat/src/clientTools/secretInteractions.ts
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts
  • web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts
  • web/packages/agenta-entities/src/secret/core/index.ts
  • web/packages/agenta-entities/src/secret/core/transforms.ts
  • web/packages/agenta-entities/src/secret/core/types.ts
  • web/packages/agenta-entities/src/secret/index.ts
  • web/packages/agenta-entities/src/workflow/index.ts
  • web/packages/agenta-entities/src/workflow/state/agentCredentials.ts
  • web/packages/agenta-entities/tests/unit/agent-credentials-commit.test.ts
  • web/packages/agenta-entities/tests/unit/secret-transforms.test.ts
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/AgentSecretsSection.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx
  • web/packages/agenta-entity-ui/src/clientTools/SecretRequestDock.tsx
  • web/packages/agenta-entity-ui/src/clientTools/SecretRequestWidget.tsx
  • web/packages/agenta-entity-ui/src/clientTools/index.ts
  • web/packages/agenta-entity-ui/src/clientTools/registry.tsx
  • web/packages/agenta-entity-ui/src/secret/AgentSecretAttachmentDrawer.tsx
  • web/packages/agenta-entity-ui/src/secret/SecretForm/SecretForm.tsx
  • web/packages/agenta-entity-ui/src/secret/SecretForm/useSecretForm.ts
  • web/packages/agenta-entity-ui/src/secret/index.ts
  • web/packages/agenta-entity-ui/tests/unit/agentSecretAttachment.test.ts
  • web/packages/agenta-playground/src/state/execution/agentRequest.ts
  • web/packages/agenta-playground/tests/unit/agentRequest.test.ts
  • web/packages/agenta-sdk/src/resources.ts
  • web/packages/agenta-shared/src/clientTools/index.ts
  • web/packages/agenta-ui/src/drill-in/context/DrillInUIContext.tsx
  • web/storybook/.storybook/main.ts
  • web/storybook/.storybook/manager-head.html
  • web/storybook/.storybook/preview-head.html
  • web/storybook/public/agent-custom-secrets/Agent custom secrets.dc.html
  • web/storybook/public/agent-custom-secrets/Flow and handoff.dc.html
  • web/storybook/public/agent-custom-secrets/_ds/agenta-design-system-0263eb0f-a904-4476-a73b-7afca7b6d749/README.md
  • web/storybook/public/agent-custom-secrets/_ds/agenta-design-system-0263eb0f-a904-4476-a73b-7afca7b6d749/_adherence.oxlintrc.json
  • web/storybook/public/agent-custom-secrets/_ds/agenta-design-system-0263eb0f-a904-4476-a73b-7afca7b6d749/_ds_bundle.js
  • web/storybook/public/agent-custom-secrets/_ds/agenta-design-system-0263eb0f-a904-4476-a73b-7afca7b6d749/colors_and_type.css
  • web/storybook/public/agent-custom-secrets/_ds/agenta-design-system-0263eb0f-a904-4476-a73b-7afca7b6d749/ui_kits/web/kit.css
  • web/storybook/public/agent-custom-secrets/support.js
  • web/storybook/stories/design/AgentCustomSecrets.stories.tsx
  • web/storybook/stories/entity-ui/AgentSecretAttachmentDrawer.stories.tsx
  • web/storybook/stories/entity-ui/SecretRequestDock.stories.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

`matrix_s1_custom_secrets.py` does not claim the browser-owned `request_secret` setup interaction. The wire driver can
observe and settle a client-tool row, but it cannot prove the host created the secret and committed
the binding through the real form. Run that pause, configure, resume, cancel, and retry flow in the
host UI using [the custom-secret browser checklist](../../../../../docs/design/agent-custom-secrets/qa-browser-checklist.md) during exploratory QA until a browser automation cell owns it.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the browser checklist link.

../../../../../docs ascends one directory past the repository root from this file. Use ../../../../docs/design/agent-custom-secrets/qa-browser-checklist.md.

value_two = f"qa-secret-{uuid.uuid4().hex}-{uuid.uuid4().hex}"
expected_one = hashlib.sha256(value_one.encode()).hexdigest()
expected_two = hashlib.sha256(value_two.encode()).hexdigest()
digest_path = f"qa-custom-secret-{token}.sha256"

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use a new result path for the rotated digest.

The second invocation reuses an existing file path. read_store_file returns the old content on its first 200 response before the durable-store overwrite becomes visible. The cell can report a failed rotation after a correct runtime update. Use a second path or wait for expected_two.

Comment on lines +86 to +93
"sdks/python/agenta/sdk/agents/sandbox_credentials.py": CUSTOM_SECRETS,
"sdks/python/agenta/sdk/agents/wire_models.py": CUSTOM_SECRETS,
"sdks/python/agenta/sdk/agents/utils/wire.py": CUSTOM_SECRETS,
"services/runner/src/engines/sandbox_agent/sandbox-credentials.ts": CUSTOM_SECRETS,
"services/runner/src/engines/sandbox_agent/run-plan.ts": CUSTOM_SECRETS,
"services/runner/src/engines/sandbox_agent/session-identity.ts": CUSTOM_SECRETS,
"services/runner/src/environment/runtime-lifecycle.ts": CUSTOM_SECRETS,
"services/runner/src/redaction.ts": CUSTOM_SECRETS,

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Cover all custom-secret delivery paths.

sdks/python/agenta/sdk/agents/handler.py resolves and serializes run credentials, and services/runner/src/lifecycle/desired-state.ts controls environment rebuilds when bindings or values change. Neither path requires matrix_s1_custom_secrets.py. A release that changes only either path can receive a false green.

  • .agents/skills/agent-release-gate/resources/path_triggers.py#L86-L93: Add both paths to CUSTOM_SECRETS.
  • .agents/skills/agent-release-gate/resources/test_custom_secret_gate.py#L7-L15: Assert that both paths activate matrix_s1_custom_secrets.py.
📍 Affects 2 files
  • .agents/skills/agent-release-gate/resources/path_triggers.py#L86-L93 (this comment)
  • .agents/skills/agent-release-gate/resources/test_custom_secret_gate.py#L7-L15

Comment on lines +131 to +132
The current PR contains the plan only. It does not implement the prompt text or the tool,
and it must not close #5703 as completed work.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the implementation status in this plan.

This section says the current PR contains only the plan, but docs/design/agent-custom-secrets/README.md and docs/design/agent-custom-secrets/qa.md describe the V1 implementation and validation. Replace this historical statement with the current status and any remaining milestone-two scope.


class SandboxEnvironmentBinding(BaseModel):
model_config = ConfigDict(extra="forbid")
type: Literal["env"]

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Default type to "env".

_SandboxEnvironmentBindingSchema declares this field with a default, but this DTO requires it. A revision that omits the redundant discriminator passes the template schema and then fails in AgentTemplate.from_params. Default the field here and add coverage for a binding that contains only name.

Proposed fix
-    type: Literal["env"]
+    type: Literal["env"] = "env"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type: Literal["env"]
type: Literal["env"] = "env"

{/* Parked question forms: one question at a time, in a fixed-height card. Slotted
between approval and connect because that is also the keyboard precedence, so
visual order and shortcut order can never disagree. */}
{secretDock ? <div className={CHAT_COLUMN}>{secretDock}</div> : null}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include secretDock in gateDockOpen to hide queued messages during secret setup.

Comment on lines +271 to +274
if (entityPropRef.current !== entityId) {
entityIdRef.current = entityId
entityPropRef.current = entityId
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge Agenta-AI/agenta /tmp/coderabbit-repo-knowledge/agenta-ai-agenta-4b53879a/conventions /tmp/coderabbit-repo-knowledge/agenta-ai-agenta-4b53879a/learnings

Length of output: 26068


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- useAgentConversation ---'
sed -n '1,360p' web/packages/agenta-chat/src/hooks/useAgentConversation.ts
printf '%s\n' '--- useAgentChatSession ---'
sed -n '1,270p' web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts

Repository: Agenta-AI/agenta

Length of output: 34039


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- remaining entity-ref and chat-binding paths ---'
rg -n -C 8 'entityIdRef|entityPropRef|adoptRevision|useSessionChat|hooks' \
  web/packages/agenta-chat/src/hooks/useAgentConversation.ts \
  web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts \
  web/packages/agenta-chat/src/hooks/useSessionChat.ts
printf '%s\n' '--- request builder definition ---'
rg -n -C 12 'export .*buildAgentRequest|function buildAgentRequest|const buildAgentRequest' \
  web/packages web/oss/src

Repository: Agenta-AI/agenta

Length of output: 36697


🌐 Web query:

React official docs refs writing during render concurrent rendering useRef

💡 Result:

In React, you must not read or write ref.current during the render phase [1][2][3]. The official documentation explicitly advises against this practice because it makes a component’s behavior unpredictable and violates the core requirement that rendering be a pure function [1][2][3]. Why this is restricted: - Rendering process: React expects that calling a component function during render will not have side effects [3]. In concurrent rendering, React may invoke your component multiple times, suspend, or abort and restart rendering [4][5]. If your component performs reads or writes to refs during these cycles, the component may observe stale, inconsistent, or incorrect values [6][7][8]. - Concurrency compatibility: Because React may "throw away" the results of a render if it is interrupted or superseded, any mutations performed during render might be triggered multiple times or never committed, leading to bugs that are difficult to debug [7][5][8]. The only exception: - Lazy initialization: It is permitted to write to a ref during render only if it is for lazy initialization, specifically when setting the initial value of a ref that will not change thereafter [1][9][3]. A common, safe pattern is: javascript const ref = useRef(null); if (ref.current === null) { ref.current = new ExpensiveObject(); } This is acceptable because the assignment happens only once during the first render and the value remains stable/predictable [1][3]. Recommended approach: - Use event handlers or useEffect for reading and writing refs [1][4][6]. These phases occur outside of the render phase (during commit or user interaction), making them the appropriate and safe locations for performing side effects [4][8]. - If you need to store information that affects what is rendered, use state (useState) instead of refs [1][2][10]. React is designed to track state changes and trigger re-renders appropriately, whereas refs are explicitly intended for values that do not trigger re-renders or affect the render output directly [2][6]. To enforce these rules, you can use the official eslint-plugin-react-hooks which includes specific rules to catch unauthorized ref access during render [6][9][7].

Citations:


🏁 Script executed:

#!/bin/bash
set -e
rg -n -C 10 'entityIdRef|entityPropRef|adoptRevision|useSessionChat|hooks' web/packages/agenta-chat/src/hooks/useAgentConversation.ts web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts web/packages/agenta-chat/src/hooks/useSessionChat.ts
rg -n -C 12 'export .*buildAgentRequest|function buildAgentRequest|const buildAgentRequest' web/packages web/oss/src

Repository: Agenta-AI/agenta

Length of output: 41845


Synchronize revision refs after commit, not during render.

Both hooks mutate entityIdRef during render, while useSessionChat preserves callbacks across renders. An interrupted render can therefore expose an uncommitted revision to buildAgentRequest, which selects the invocation URL by revision ID. Move the prop-to-ref synchronization into a layout effect in both hooks.

📍 Affects 2 files
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts#L271-L274 (this comment)
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts#L175-L178

},
{queryParams: {project_id: projectId}},
)
revision = workflowRevisionResponseSchema.parse(response).workflow_revision

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use safeParseWithLogging here, as per coding guidelines: “Use safeParseWithLogging for the validation.”

Source: Coding guidelines

onAdoptRevision,
onOutput,
}: SecretRequestDockProps) => {
const [targetId, setTargetId] = useState(revisionId)

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline web/packages/agenta-entity-ui/src/clientTools/SecretRequestDock.tsx --items all
rg -n -C 6 'SecretRequestDock|revisionId=|onAdoptRevision' web --glob '*.ts' --glob '*.tsx'

Repository: Agenta-AI/agenta

Length of output: 50373


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- SecretRequestDock ---'
cat -n web/packages/agenta-entity-ui/src/clientTools/SecretRequestDock.tsx

printf '%s\n' '--- SecretRequestDock call sites ---'
rg -n -C 12 '<SecretRequestDock|SecretRequestDock' web --glob '*.ts' --glob '*.tsx' \
  | rg -v 'node_modules|SecretRequestDock\.tsx'

printf '%s\n' '--- adoption and revision state ---'
rg -n -C 14 'adoptSecretRevision|const entityId|entityId[),]|revisionId.*entityId' \
  web/mobile/src/features/chat/LiveConversation.tsx

Repository: Agenta-AI/agenta

Length of output: 31118


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat -n web/packages/agenta-entity-ui/src/clientTools/SecretRequestDock.tsx
printf '%s\n' '--- exact call sites ---'
rg -n -C 10 '<SecretRequestDock' web --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- revision adoption ---'
rg -n -C 12 'adoptSecretRevision|entityId' web/mobile/src/features/chat/LiveConversation.tsx

Repository: Agenta-AI/agenta

Length of output: 21622


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- conversation revision adoption ---'
rg -n -C 12 'adoptRevision' web/mobile web/oss web/packages --glob '*.ts' --glob '*.tsx'

printf '%s\n' '--- LiveConversation hosts ---'
rg -n -C 10 '<LiveConversation|LiveConversation\(' web/mobile web/oss --glob '*.tsx'

printf '%s\n' '--- entityId updates in conversation hosts ---'
rg -n -C 8 'entityId.*set|setEntityId|selectedRevision|revisionId' web/mobile/src web/oss/src/components/AgentChatSlice --glob '*.ts' --glob '*.tsx' \
  | head -n 300

Repository: Agenta-AI/agenta

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- mobile key and selected revision flow ---'
sed -n '55,105p' web/mobile/src/features/chat/ChatScreen.tsx
cat -n web/mobile/src/features/chat/conversationKey.ts
cat -n web/mobile/src/features/chat/selectedRevision.ts

printf '%s\n' '--- desktop AgentConversation hosts ---'
rg -n -C 12 '<AgentConversation|AgentConversation\(' web/oss/src --glob '*.tsx'

printf '%s\n' '--- desktop entity switching ---'
rg -n -C 14 'switchEntity' web/oss/src/components/AgentChatSlice --glob '*.ts' --glob '*.tsx'

Repository: Agenta-AI/agenta

Length of output: 22453


Synchronize targetId with revisionId. Both chat hosts keep SecretRequestDock mounted when the revision changes: the mobile conversationKey ignores revisionId, and the desktop conversation survives entityId changes. targetId then remains stale, so the drawer and commitAgentCredentialsAtom can read and update the previous revision.


class Component extends DCLogic {
timers = [];
state = this.build(new URLSearchParams(location.search).get("scenario") || "happy");

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate the initial scenario value.

An unknown scenario query value makes SCENARIOS.find(...) return undefined, then line 795 throws on .hint. Default unsupported values to "happy" before calling build.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant