Skip to content

Commit a23448d

Browse files
committed
Fixed some continuation of agents
1 parent 69d488b commit a23448d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

shared.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16272,7 +16272,7 @@ func handleAgentDecisionStreamResult(workflowExecution WorkflowExecution, action
1627216272
// Find next action
1627316273
allFinishedDecisions := []string{}
1627416274
for decisionId, curDecision := range mappedResult.Decisions {
16275-
if curDecision.RunDetails.Status == "FINISHED" {
16275+
if curDecision.RunDetails.Status == "FINISHED" || curDecision.RunDetails.Status == "IGNORED" {
1627616276
allFinishedDecisions = append(allFinishedDecisions, curDecision.RunDetails.Id)
1627716277
} else if curDecision.RunDetails.Status == "FAILURE" {
1627816278
if debug {
@@ -16327,7 +16327,7 @@ func handleAgentDecisionStreamResult(workflowExecution WorkflowExecution, action
1632716327
}
1632816328
}
1632916329

16330-
log.Printf("[INFO] TOTAL AGENT DECISIONS: %#v, FINISHED DECISIONS: %#v. Missing decision IDs: %#v", len(mappedResult.Decisions), len(allFinishedDecisions), allFinishedDecisions)
16330+
log.Printf("[INFO] TOTAL AGENT DECISIONS: %#v, FINISHED DECISIONS: %#v. Finished decision IDs: %#v", len(mappedResult.Decisions), len(allFinishedDecisions), allFinishedDecisions)
1633116331

1633216332
// FIXME: How do we handle 3rd party memory sources?
1633316333
// This uses the built-in datastore mechanism so that the user
@@ -23823,6 +23823,12 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2382323823
// The only key we care about in this case
2382423824
if key == "continue" {
2382523825
// Overwrite everything
23826+
if workflowExecution.Status == "FINISHED" {
23827+
workflowExecution.Status = "EXECUTING"
23828+
}
23829+
23830+
unmarshalledDecision.Status = "RUNNING"
23831+
unmarshalledDecision.Output = ""
2382623832
decision.Fields = []Valuereplace{
2382723833
Valuereplace{
2382823834
Key: "continue",
@@ -23834,7 +23840,10 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2383423840
decision.Action = "ask"
2383523841
decision.Tool = "ask"
2383623842
decision.Category = "standalone"
23837-
decision.Reason = "Continued by adding task details"
23843+
23844+
// Make the value max 50 bytes
23845+
decision.Reason = fmt.Sprintf("User Input: %.50s", value)
23846+
unmarshalledDecision.Decisions[decisionIndex] = decision
2383823847

2383923848
fieldsChanged = true
2384023849
cleanupFailures = true
@@ -23892,15 +23901,12 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2389223901
// This is a concept to allow for better UX
2389323902
// Only runs if you "continue" running an agent run
2389423903
if cleanupFailures {
23895-
log.Printf("\n\n\nRunning CLEANUP!!\n\n\n")
2389623904
for decisionIndex, _ := range unmarshalledDecision.Decisions {
2389723905
decision := unmarshalledDecision.Decisions[decisionIndex]
2389823906
if decision.RunDetails.Status != "FAILURE" {
2389923907
continue
2390023908
}
2390123909

23902-
log.Printf("\n\n\nFOUND FAILURE TO CLEANUP!!\n\n\n")
23903-
2390423910
decision.RunDetails.Status = "IGNORED"
2390523911
unmarshalledDecision.Decisions[decisionIndex] = decision
2390623912

@@ -23938,16 +23944,14 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
2393823944
oldExecution.Results[resultIndex] = result
2393923945

2394023946
// FIXME: Can we force continue the agent from here? Or do we send another action inbetween?
23941-
// go sendAgentActionSelfRequest("SUCCESS", workflowExecution, workflowExecution.Results[foundActionResultIndex])
23942-
2394323947
result.Status = fmt.Sprintf("%s_%s", "FINISHED", decisionId)
23944-
2394523948
newExec, _, err := handleAgentDecisionStreamResult(*oldExecution, result)
2394623949
if err != nil {
2394723950
log.Printf("[ERROR][%s] Failed handling agentic decision result: %s", oldExecution.ExecutionId, err)
2394823951
}
2394923952

2395023953
return *newExec, ExecInfo{}, fmt.Sprintf("Agentic question handled (%s)", oldExecution.ExecutionId), errors.New("User Input: Agentic question action handled successfully!")
23954+
2395123955
} else if result.Status == "WAITING" && !agentic {
2395223956
log.Printf("[INFO][%s] Found relevant User Input result: %s (%s)", result.ExecutionId, result.Action.Label, result.Action.ID)
2395323957

0 commit comments

Comments
 (0)