You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: remove blocking I/O from ExecuteAgentAction mutation (Refs: beans-bbg1) (#152)
## Summary
- Removed all blocking I/O (git status checks, forge API calls, worktree
listing) from the `ExecuteAgentAction` mutation resolver, which was
causing a noticeable delay between clicking action buttons and the
message appearing in chat
- Simplified action prompts to let agents gather their own context
instead of pre-fetching it — the agent will run `git status`, `gh pr
view`, etc. as part of doing the actual work
- The `AgentActions` query (which powers button visibility/disabled
state) is unaffected and still does its own context gathering
## Test plan
- [x] Unit tests pass (`TestExecuteAgentAction`,
`TestAgentActionRegistry`)
- [ ] Manual: click Review, Learn, Commit, Create PR buttons — messages
should appear in chat noticeably faster
- [ ] Manual: verify commit action still produces appropriate commit
messages
- [ ] Manual: verify create-pr action still correctly handles all states
(no PR, existing PR, failing checks, mergeable)
title: Remove pre-fetched context from ExecuteAgentAction, let agents gather their own context
4
+
status: completed
5
+
type: task
6
+
priority: normal
7
+
created_at: 2026-03-18T09:59:28Z
8
+
updated_at: 2026-03-18T10:01:19Z
9
+
---
10
+
11
+
## Summary of Changes
12
+
13
+
Removed all blocking I/O (git status checks, forge API calls, worktree listing) from the `ExecuteAgentAction` mutation resolver. The mutation now only passes static context (working directory path, main repo path, forge CLI name) to prompt generation. The agents themselves will inspect git state and PR status as needed.
14
+
15
+
Simplified prompts:
16
+
-**commit**: Single prompt that tells the agent to inspect git status itself
17
+
-**create-pr**: Single unified prompt that tells the agent to check PR state and take the appropriate action, instead of pre-branching into 4 different prompts based on pre-fetched state
18
+
-**integrate**: Unchanged (only used `MainRepoPath`, which is a path lookup, not I/O)
19
+
-**review/learn/tests**: Already didn't use context, unchanged
- Derive the PR title from the branch name and commit messages. Use a conventional commit style prefix.
362
-
- Write a meaningful PR body summarizing the changes.
363
-
- Include any relevant bean IDs.
307
+
returnfmt.Sprintf(`Manage the pull request for this branch. Check the current state and take the appropriate action:
308
+
309
+
1. Check if a PR already exists: %[1]s pr view
310
+
2. Check for uncommitted changes (git status) and unpushed commits (git log @{upstream}..HEAD).
311
+
3. Based on the state:
312
+
- **No PR exists**: Commit any uncommitted changes, push the branch (git push -u origin HEAD), and create a PR (%[1]s pr create). Derive the title from commit messages using conventional commit style. Include relevant bean IDs.
313
+
- **PR exists, has local changes or unpushed commits**: Commit if needed, then push (git push). Update the PR title/body if the scope changed.
314
+
- **PR exists, everything pushed, checks failing**: Inspect the failed checks (%[1]s pr checks, %[1]s run view --log-failed), fix the issue, test locally, commit and push.
315
+
- **PR exists, everything pushed, checks pass, mergeable**: Merge it. Use %[1]s repo view --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed to pick the right strategy, then %[1]s pr merge with the appropriate flag. Do NOT switch branches after merging.
364
316
4. Report the PR URL when done.`, cli)
365
317
},
366
318
Visible: func(ctxactionContext) bool {
@@ -399,26 +351,9 @@ Push the latest changes to update it:
399
351
},
400
352
}
401
353
402
-
// commitPrompt inspects the working directory to generate an appropriate commit prompt.
403
-
funccommitPrompt(ctxactionContext) string {
404
-
changes, err:=gitutil.FileChanges(ctx.WorkDir)
405
-
iferr!=nil||len(changes) ==0 {
406
-
return"Create a commit. Examine the git diff and commit the changes with an appropriate message."
407
-
}
408
-
409
-
allBeans:=true
410
-
for_, c:=rangechanges {
411
-
if!strings.HasPrefix(c.Path, ".beans/") {
412
-
allBeans=false
413
-
break
414
-
}
415
-
}
416
-
417
-
ifallBeans {
418
-
return"Create a commit. The only uncommitted changes are bean files. Examine them and commit with an appropriate message describing the bean updates (e.g. status changes, new beans, archived beans)."
419
-
}
420
-
421
-
return"Create a commit. Make sure there is an associated bean that is up to date, and possibly even marked as completed if you are done with the change. Then only commit changes related to that change."
354
+
// commitPrompt generates a commit prompt. The agent will inspect git state itself.
355
+
funccommitPrompt(_actionContext) string {
356
+
return"Create a commit. Examine the current git status and diff, then commit with an appropriate message. If there are non-bean changes, make sure there is an associated bean that is up to date. If the only changes are bean files, describe the bean updates in the commit message."
422
357
}
423
358
424
359
// findAgentAction looks up an action by ID, returning nil if not found.
0 commit comments