DEV-000069 general agent delegation codex bridge foundation
This commit is contained in:
@@ -41,7 +41,7 @@ func InterpretHumanResponse(request contract.HumanResponseRequest, owner identit
|
||||
Revision: 1,
|
||||
UserReportedNotVerified: false,
|
||||
}
|
||||
if operation == contract.ResponseUnknown || operation == contract.ResponseContinue || operation == contract.ResponseReject {
|
||||
if operation == contract.ResponseUnknown {
|
||||
return contract.HumanResponseResult{Response: response, Handled: false}, nil
|
||||
}
|
||||
if len(candidates) == 0 {
|
||||
@@ -67,11 +67,22 @@ func InterpretHumanResponse(request contract.HumanResponseRequest, owner identit
|
||||
response.TargetKind = contract.ResponseTargetAttentionItem
|
||||
response.TargetAttentionID = candidate.Attention.ID
|
||||
response.TargetProspectiveID = candidate.Attention.SourceProspectiveID
|
||||
response.TargetExternalRef = candidate.Attention.SourceExternalRef
|
||||
} else {
|
||||
response.TargetKind = contract.ResponseTargetProspectiveItem
|
||||
response.TargetProspectiveID = candidate.Prospective.ID
|
||||
}
|
||||
response.ResolutionState = contract.ResponseResolved
|
||||
if response.TargetExternalRef != "" && candidate.Attention.SourceKind == contract.AttentionSourceAgentDelegation {
|
||||
switch operation {
|
||||
case contract.ResponseContinue:
|
||||
response.Outcome = contract.ResponseOutcomeContinued
|
||||
return contract.HumanResponseResult{Response: response, Handled: true, Reply: "Принял. Продолжаю работу по этой задаче."}, nil
|
||||
case contract.ResponseReject:
|
||||
response.Outcome = contract.ResponseOutcomeRejected
|
||||
return contract.HumanResponseResult{Response: response, Handled: true, Reply: "Понял. Зафиксировал, что здесь нужно другое решение."}, nil
|
||||
}
|
||||
}
|
||||
switch operation {
|
||||
case contract.ResponseComplete:
|
||||
response.Outcome = contract.ResponseOutcomeUserReportedComplete
|
||||
|
||||
@@ -87,6 +87,42 @@ func TestInterpretHumanResponseNoTargetAsksClarification(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretHumanResponseContinuesAgentDelegationAttention(t *testing.T) {
|
||||
result := interpretResponseForTest(t, "Продолжай", []ResponseCandidate{{
|
||||
Attention: continuity.AttentionItem{
|
||||
ID: "attention-1",
|
||||
OwnerPrincipalID: "principal-1",
|
||||
ScopeID: "scope-1",
|
||||
SourceKind: continuity.AttentionSourceAgentDelegation,
|
||||
SourceExternalRef: "work:delegation:delegation-1",
|
||||
State: continuity.AttentionDelivered,
|
||||
Summary: "нужен твой выбор по задаче coding-agent",
|
||||
Revision: 1,
|
||||
},
|
||||
}})
|
||||
if !result.Handled || result.Response.Operation != continuity.ResponseContinue || result.Response.Outcome != continuity.ResponseOutcomeContinued || result.Response.TargetExternalRef != "work:delegation:delegation-1" {
|
||||
t.Fatalf("unexpected delegation continue response: %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretHumanResponseRejectsAgentDelegationAttention(t *testing.T) {
|
||||
result := interpretResponseForTest(t, "Нет, нужен другой вариант", []ResponseCandidate{{
|
||||
Attention: continuity.AttentionItem{
|
||||
ID: "attention-1",
|
||||
OwnerPrincipalID: "principal-1",
|
||||
ScopeID: "scope-1",
|
||||
SourceKind: continuity.AttentionSourceAgentDelegation,
|
||||
SourceExternalRef: "work:delegation:delegation-1",
|
||||
State: continuity.AttentionDelivered,
|
||||
Summary: "нужен твой выбор по задаче coding-agent",
|
||||
Revision: 1,
|
||||
},
|
||||
}})
|
||||
if !result.Handled || result.Response.Operation != continuity.ResponseReject || result.Response.Outcome != continuity.ResponseOutcomeRejected {
|
||||
t.Fatalf("unexpected delegation reject response: %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func interpretResponseForTest(t *testing.T, message string, candidates []ResponseCandidate) continuity.HumanResponseResult {
|
||||
t.Helper()
|
||||
result, err := InterpretHumanResponse(continuity.HumanResponseRequest{
|
||||
|
||||
Reference in New Issue
Block a user