Files
tutti/packages/agent/daemon/runtime/codex_appserver_goal_fence.go
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

64 lines
1.9 KiB
Go

package agentruntime
import (
"context"
"errors"
"strings"
)
func (a *CodexAppServerAdapter) FenceGoalGeneration(
_ context.Context,
session Session,
input GoalGenerationFenceInput,
) error {
identity := goalOperationIdentity{
operationID: strings.TrimSpace(input.OperationID),
revision: input.Revision,
repairEpoch: input.RepairEpoch,
}
if !identity.valid() {
return errors.New("valid Goal generation fence identity is required")
}
a.mu.Lock()
appSession := a.sessions[strings.TrimSpace(session.AgentSessionID)]
if appSession == nil || appSession.client == nil {
a.mu.Unlock()
return ErrSessionDisconnected
}
if appSession.fencedGoalIdentities == nil {
appSession.fencedGoalIdentities = make(map[goalOperationIdentity]struct{})
}
appSession.fencedGoalIdentities[identity] = struct{}{}
if claim := appSession.goalContinuationClaim; claim != nil && claim.identity == identity {
appSession.goalContinuationClaim = nil
}
active := appSession.activeTurn
client, threadID := appSession.client, appSession.threadID
activeMatches := active != nil && active.goalIdentity == identity
providerTurnID := ""
if activeMatches {
providerTurnID = active.providerTurnID
}
a.mu.Unlock()
if activeMatches && strings.TrimSpace(providerTurnID) != "" {
return exactQuiesceGoalTurn(client, threadID, providerTurnID)
}
return nil
}
func goalIdentityFencedLocked(appSession *codexAppServerSession, identity goalOperationIdentity) bool {
if appSession == nil || !identity.valid() {
return false
}
_, fenced := appSession.fencedGoalIdentities[identity]
return fenced
}
func (a *CodexAppServerAdapter) quiesceFencedGoalTurn(session Session, providerTurnID string) {
appSession := a.getSession(session.AgentSessionID)
if appSession == nil || appSession.client == nil {
return
}
_ = exactQuiesceGoalTurn(appSession.client, appSession.threadID, providerTurnID)
}