Skip to content

Several Agent fixes#413

Draft
satti-hari-krishna-reddy wants to merge 15 commits into
Shuffle:mainfrom
satti-hari-krishna-reddy:agent-workflow
Draft

Several Agent fixes#413
satti-hari-krishna-reddy wants to merge 15 commits into
Shuffle:mainfrom
satti-hari-krishna-reddy:agent-workflow

Conversation

@satti-hari-krishna-reddy

@satti-hari-krishna-reddy satti-hari-krishna-reddy commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

This PR includes several different fixes for the agent:

  1. Fixed an agent parsing bug that was breaking runs. Added multiple fallbacks to improve reliability.
  2. Resolved a continuation issue where the LLM would forget the original user request.
  3. Made updates to the agent workflow building function.

Comment thread shared.go Outdated
item := "node" // default
opType := ""
switch operation.Op {
case "add_node":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got a feeling that we could have done this more smartly.

would have been so much more cleaner if case could simply match up with item + opType. Is that possible?

@satti-hari-krishna-reddy satti-hari-krishna-reddy changed the title fix: Agent parsing bug Several Agent fixes Jun 29, 2026

@frikky frikky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm scared of how many potential nil-pointers you may have introduced.

4 lines doing 1 thing each >>>>> 1 line doing 4 things

Comment thread ai.go Outdated

// So lets decode into raw maps so we can inspect and mutate it
var raw []map[string]interface{}
if err := json.NewDecoder(strings.NewReader(s[i:])).Decode(&raw); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of stuff is scary. Always split into multiple at a time if possible, and verify indexing.

Comment thread ai.go Outdated
continue
}

if len(raw) == 0 || raw[0]["action"] == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if "action" doesn't exist in the first object?

Comment thread ai.go Outdated
}

// Fix the types (convert numbers/bools to strings)
normalizeDecisionFields(raw)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's gonna normalize, doesn't it need to return &raw?

Or are pointer mappings enough?

Comment thread ai.go Outdated
continue
}

r := strings.NewReader(s[i:])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why s[i:]? Just to read from current index until end? Feels weird without a moving window

Comment thread ai.go Outdated
continue
}

if raw["action"] != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, validation

Comment thread ai.go Outdated
}

if raw["action"] != nil {
normalizeDecisionFields([]map[string]interface{}{raw})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid this kind of pointer magic please. And pre-declare values.

This isn't easily understandable/readable

Comment thread ai.go Outdated
}

for _, f := range fields {
fm, ok := f.(map[string]interface{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm scared when we do casting -> check values (:

Comment thread ai.go Outdated
// This MUST happen before unmarshalling into AgentDecision (whose Value field is a string).
func normalizeDecisionFields(decisions []map[string]interface{}) {
for _, d := range decisions {
fields, ok := d["fields"].([]interface{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't cast AND check if it exists at the same time. Separate.

@satti-hari-krishna-reddy satti-hari-krishna-reddy marked this pull request as draft June 30, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants