agent build

This commit is contained in:
2026-08-28 12:21:44 +05:30
parent b6f8655909
commit f7df96c973
138 changed files with 24164 additions and 207 deletions

View File

@@ -2,6 +2,7 @@ package runtime
import (
"context"
"fmt"
"github.com/krow/krow-backend/go-api/internal/authctx"
"github.com/krow/krow-backend/go-api/internal/repo"
@@ -88,13 +89,27 @@ func NewEngine(db repo.Querier, opts ...Option) *Engine {
// RunAgent loads an executable agent with dependencies and dispatches to the executor boundary.
func (e *Engine) RunAgent(ctx context.Context, ident authctx.Identity, idOrDefID string, input ExecutionInput) (*ExecutionResult, error) {
agent, err := e.Loader.LoadExecutableAgent(ctx, ident, idOrDefID)
// A pinned run loads the agent AS IT WAS. §3: running conversations pin the
// version they started with — which matters most on a resumed run, where a
// person approved a write while looking at one version and an edit may have
// landed since.
agent, unpinned, err := e.Loader.LoadAgentVersion(ctx, ident, idOrDefID, input.AgentVersion)
if err != nil {
return &ExecutionResult{
Success: false,
Error: err,
}, err
}
if unpinned {
// Asked for a version that has no snapshot — a definition published
// before versions were recorded. The run proceeds on the current
// definition rather than failing, and says so, because a silent
// substitution is the thing worth preventing.
input.Notes = append(input.Notes, fmt.Sprintf(
"version_unavailable: version %d of %s is not in the published history; "+
"this run used the current definition (v%d)",
input.AgentVersion, agent.ID, agent.Version))
}
res, err := e.AgentExec.ExecuteAgent(ctx, agent, input)
if res == nil {