Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/core/lib/v3/agent/tools/fillform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ export const fillFormTool = (

const completed = [] as unknown[];
const replayableActions: Action[] = [];
for (const res of observeResults) {
for (let i = 0; i < observeResults.length; i++) {
const res = observeResults[i];

if (res.method === "fill" && fields[i] !== undefined) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

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

P1: Form values are injected by observe-result index, which can misbind values to the wrong fill action when observe output ordering/count differs from input fields.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/lib/v3/agent/tools/fillform.ts, line 62:

<comment>Form values are injected by observe-result index, which can misbind values to the wrong fill action when observe output ordering/count differs from input fields.</comment>

<file context>
@@ -56,7 +56,13 @@ export const fillFormTool = (
+        for (let i = 0; i < observeResults.length; i++) {
+          const res = observeResults[i];
+
+          if (res.method === "fill" && fields[i] !== undefined) {
+            res.arguments = [fields[i].value];
+          }
</file context>
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

This is theoretically valid but not a practical concern. The instruction sent to observe() lists actions in explicit order, and the LLM returns results corresponding to that ordered list.

The original code already had this same implicit assumption—it looped over observeResults and called act() without any correlation mechanism. This fix does not introduce a new ordering assumption.

There is no ID or correlation mechanism between fields and observe results in the existing API, so index-based matching is the only option without a larger architectural refactor, which is out of scope for this bug fix.

res.arguments = [fields[i].value];
}

const actOptions = variables
? { variables, timeout: toolTimeout }
: { timeout: toolTimeout };
Expand Down