fix: pass workspace from YAML import to agent definition#35
fix: pass workspace from YAML import to agent definition#35dajiaohuang wants to merge 3 commits into
Conversation
When importing a project via YAML, the workspace was parsed and stored in the normalized spec but never bound to the agent. The AgentDefinition.WorkspaceID was always empty, so agents started in an empty directory. Resolve workspace from agent-level spec first, falling back to project-level. Generate a deterministic workspace ID from the spec fields so repeated imports do not create duplicates. Fixes chaitin#33
|
Thanks for the fix. The direction makes sense to me: YAML-imported managed agents should not lose the workspace declared in the project spec, especially when the managed agent is started outside the project-run path. One thing I am not fully sure about from this patch: Project runs already seem to materialize workspace from the project revision spec at run time, so this mainly matters for using the imported managed agent through the normal agent-definition/session path. Could we confirm that the matching workspace config is persisted somewhere, or add that as part of this change? A regression test that applies a project with project-level + agent-level workspace and then verifies the managed agent workspace resolves successfully would make this much clearer. |
|
Following up on the workspace persistence concern above. I think this still needs a small but important follow-up before the PR can land: the managed AgentDefinition now gets a deterministic WorkspaceID, but I still cannot find where ApplyProject creates or upserts the matching WorkspaceConfig. Since CreateAgentSession validates that WorkspaceID through GetWorkspaceConfig, the imported managed agent may fail with Could you take another look and either point me to the persistence path I missed, or update the PR to materialize/upsert the workspace config and add a regression test for ApplyProject -> managed AgentDefinition -> CreateAgentSession? Happy to re-review once updated. |
When importing a project via YAML with a workspace, the agent definition gets a deterministic WorkspaceID but the matching WorkspaceConfig was never created. CreateAgentSession validates WorkspaceID existence via GetWorkspaceConfig, so the imported agent would fail with "workspace config <id> not found". This change: - Adds UpsertWorkspaceConfig to ConfigStore for idempotent persistence - Materializes WorkspaceConfig rows during ApplyProject before agent definitions are reconciled - Deduplicates by StableWorkspaceID so re-imports are safe Fixes chaitin#33
|
Thanks for the careful review. The gap you identified is real — the What was fixed:
The workspace config created during apply uses the same deterministic |
|
I took another look at the latest fix. The overall direction makes sense: once the managed agent stores a stable workspace id,
Repro: go test ./pkg/agentcompose -run 'TestProjectServiceApplyProjectUpsertsWorkspaceConfigs' -count=1It may be worth making the semantics explicit here: either the API/test should always send
I also ran: go test ./pkg/composeThat one passes. Once the two workspace handling details above are addressed, this PR should be in much better shape. |
- Auto-detect git provider from URL presence when provider is empty so that workspace specs with url/branch/path but no explicit provider resolve to type 'git' instead of 'file'. - Snapshot local workspace source directory into the file workspace content root during project apply so that agent sessions start with the project files rather than an empty directory. - Add test coverage for git auto-detection and local workspace content population. Co-Authored-By: Claude <noreply@anthropic.com>
|
Hey @eetoc, thanks for the review! I have addressed both issues you raised: 1. Provider type mismatch (#35 (comment)) Added auto-detection: when Added test coverage in 2. Local workspace not populated For Added
|
Summary
When importing a project via YAML, the workspace was parsed and stored in the normalized spec but never bound to the agent.
AgentDefinition.WorkspaceIDwas always empty, so agents started in an empty directory.Agent-level workspace takes precedence; project-level workspace is used as fallback.
Testing
go build ./pkg/compose/andgo build ./pkg/agentcompose/pass.Checklist
Fixes #33