Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Add a focused restoration test covering same-type subtask chains and NULL scopes.
Pull request overview
This PR scopes restored message-chain lookups to the exact flow, task, subtask, and type.
Changes:
- Added a nullable-safe scoped lookup.
- Updated
restoreChainto use it. - Regenerated sqlc code and added parameter tests.
File summaries
| File | Summary |
|---|---|
backend/sqlc/models/msgchains.sql |
Adds the scoped lookup query. |
backend/pkg/providers/helpers.go |
Uses scoped restoration parameters. |
backend/pkg/providers/helpers_test.go |
Tests scope parameter mapping. |
backend/pkg/database/querier.go |
Exposes the generated query method. |
backend/pkg/database/msgchains.sql.go |
Implements the generated query. |
Review details
Files not reviewed (2)
- backend/pkg/database/msgchains.sql.go: Generated file
- backend/pkg/database/querier.go: Generated file
Suppressed comments (1)
backend/pkg/providers/helpers.go:472
- The added test only verifies conversion to
sql.NullInt64; it would still pass ifrestoreChaincalled the old task/type lookup or if the SQL predicate returned another subtask's row. Please add a focused restore/database test with two same-type chains in one task and assert that restoring each subtask selects its own chain (including the NULL/NULL scope).
msgChain, err := fp.db.GetFlowTaskSubtaskTypeLastMsgChain(ctx, scopedMsgChainLookupParams(
fp.flowID, taskID, subtaskID, msgChainType,
))
- Files reviewed: 3/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
restoreChainuse the scoped lookup so it cannot inherit a same-type chain from another subtaskProblem
restoreChaincurrently selects the latest chain by flow, task, and type. When multiple subtasks use the same specialist type, restoring one subtask can therefore load another subtask’s chain and append the new prompt to unrelated tool history. Besides mixing execution context, that history can grow increasingly expensive to normalize and summarize.The new query uses PostgreSQL
IS NOT DISTINCT FROMfor both nullable identifiers, so assistant (NULL/NULL), task-only, and subtask-scoped chains each match their exact scope.Validation
go test ./pkg/providers ./pkg/database/... -count=1go build ./cmd/pentagigit diff --check