-
Notifications
You must be signed in to change notification settings - Fork 2
address code rabbit comments #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bb15475
address code rabbit comments
riatzukiza bda6b12
impoved auto review response flow
riatzukiza e4bf799
Preserve compaction context when stripping commands
riatzukiza 74c6155
Fix duplicate import in compaction helper test
riatzukiza 4540ec3
Added RequestBody mutation assertions to tests.
opencode-agent[bot] 07b5591
Added equality assertion to test input immutability
opencode-agent[bot] 7466b2b
Fixed failing test assertion for compaction
opencode-agent[bot] a5a8a58
Update test/compaction-helpers.test.ts
riatzukiza 0c8ed15
Updated test title to match assertions
opencode-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Review-response workflow token alignment | ||
|
|
||
| ## Context | ||
|
|
||
| - File: .github/workflows/review-response.yml (lines 1-106) | ||
| - Behavior: Responds to PR review comments; checks out PR head and pushes auto-fix branch using default GITHUB_TOKEN. | ||
| - Issue: Org policy blocks PR creation/push via default `GITHUB_TOKEN`; dev-release-prep uses `PR_AUTOMATION_TOKEN` validated explicitly. | ||
| - Existing related workflow: .github/workflows/dev-release-prep.yml uses `PR_AUTOMATION_TOKEN` for PR creation and validates secret. | ||
|
|
||
| ## Requirements / Definition of Done | ||
|
|
||
| - review-response workflow uses `secrets.PR_AUTOMATION_TOKEN` for all GitHub write operations (push, PR creation, gh api/cli) instead of default GITHUB_TOKEN. | ||
| - Validate presence of PR_AUTOMATION_TOKEN early with a failure message mirroring dev-release-prep wording. | ||
| - Keep OPENCODE_API_KEY handling unchanged. | ||
| - Ensure checkout/push/pr steps reference the new token via env (GH_TOKEN and git auth) so branch push + PR creation succeed under org policy. | ||
| - Review-response branches should be named `review/<base>-<review-id>`. | ||
| - Release automation should treat `review/*` branches as non-release and avoid version bumps. | ||
| - Tests/build unaffected (workflow-only change). | ||
|
|
||
| ## Open Questions / Notes | ||
|
|
||
| - No other review-response workflows present. | ||
| - PAT must have repo permissions; assumes secret already configured in repo/org. | ||
| - Checkout of fork PRs may still require permission; pushing uses PAT. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Review v0.3.5 fixes | ||
|
|
||
| ## Scope | ||
|
|
||
| - Handle null/empty cache reads in `lib/prompts/codex.ts` around readCachedInstructions caching logic | ||
| - Remove redundant cloning in `lib/request/compaction-helpers.ts` (removeLastUserMessage, maybeBuildCompactionPrompt) | ||
| - Prevent duplicate tool remap injection in `lib/request/input-filters.ts` addToolRemapMessage | ||
|
|
||
| ## Existing issues / PRs | ||
|
|
||
| - None identified for this branch (review/v0.3.5). | ||
|
|
||
| ## Definition of done | ||
|
|
||
| - safeReadFile null results do not get cached as empty content; fallback logic remains available for caller | ||
| - Compaction helpers avoid unnecessary clones while preserving immutability semantics (original input reused unless truncated) | ||
| - Tool remap message is only prepended once when tools are present; logic handles undefined/null safely | ||
| - All relevant tests updated or added if behavior changes; existing suite passes locally if run | ||
|
|
||
| ## Requirements / notes | ||
|
|
||
| - Only cache instructions when actual non-empty content is read; on null either warn and return null or allow existing fallback paths | ||
| - removeLastUserMessage should find last user role index and slice; when commandText is falsy reuse originalInput directly in maybeBuildCompactionPrompt | ||
| - addToolRemapMessage should fingerprint or compare TOOL_REMAP_MESSAGE and skip if already present (matching role/type/text) | ||
| - Preserve existing function signatures and return types throughout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { applyCompactionIfNeeded } from "../lib/request/compaction-helpers.js"; | ||
| import type { InputItem, RequestBody } from "../lib/types.js"; | ||
|
|
||
| describe("compaction helpers", () => { | ||
| it("drops only the last user command and keeps trailing items", () => { | ||
| const originalInput: InputItem[] = [ | ||
| { type: "message", role: "assistant", content: "previous response" }, | ||
| { type: "message", role: "user", content: "/codex-compact please" }, | ||
| { type: "message", role: "assistant", content: "trailing assistant" }, | ||
| ]; | ||
| const body: RequestBody = { model: "gpt-5", input: [...originalInput] }; | ||
|
|
||
| const decision = applyCompactionIfNeeded(body, { | ||
| settings: { enabled: true }, | ||
| commandText: "codex-compact please", | ||
| originalInput, | ||
| }); | ||
|
|
||
| expect(decision?.mode).toBe("command"); | ||
| expect(decision?.serialization.transcript).toContain("previous response"); | ||
| expect(decision?.serialization.transcript).toContain("trailing assistant"); | ||
| expect(decision?.serialization.transcript).not.toContain("codex-compact please"); | ||
|
|
||
| // Verify RequestBody mutations | ||
| expect(body.input).not.toEqual(originalInput); | ||
| expect(body.input?.some((item) => item.content === "/codex-compact please")).toBe(false); | ||
| expect((body as any).tools).toBeUndefined(); | ||
| expect((body as any).tool_choice).toBeUndefined(); | ||
| expect((body as any).parallel_tool_calls).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("applies compaction when no user message exists", () => { | ||
| const originalInput: InputItem[] = [ | ||
| { | ||
| type: "message", | ||
| role: "assistant", | ||
| content: "system-only follow-up", | ||
| }, | ||
| ]; | ||
| const body: RequestBody = { model: "gpt-5", input: [...originalInput] }; | ||
|
|
||
| const decision = applyCompactionIfNeeded(body, { | ||
| settings: { enabled: true }, | ||
| commandText: "codex-compact", | ||
| originalInput, | ||
| }); | ||
|
|
||
| expect(decision?.serialization.totalTurns).toBe(1); | ||
| expect(decision?.serialization.transcript).toContain("system-only follow-up"); | ||
|
|
||
| // Verify RequestBody mutations | ||
| expect(body.input).toBeDefined(); | ||
| expect(body.input?.length).toBeGreaterThan(0); | ||
| expect(body.input).not.toEqual(originalInput); | ||
| expect((body as any).tools).toBeUndefined(); | ||
| expect((body as any).tool_choice).toBeUndefined(); | ||
| expect((body as any).parallel_tool_calls).toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.