Repository navigation
feat(prompts): show Improve the brand's earlier Improve rounds on the prompt (learning B5, part 2) - #1693
Merged
Conversation
… prompt Learning B5, part 2. Improve wrote its suggestions from the answers only, so it could suggest again what an earlier round did on a platform that didn't move, and never built on what moved. - loadImproveRounds: the brand's last two prompt_improve actions on the prompt (not dismissed or deleted, never another brand's), each with how its platforms moved (position_outcome, final a month after it was completed) and its suggestions, done or not. - buildImprovePrompt adds an "Earlier Improve rounds" block and asks to build on what moved and not to repeat what was done on a platform that didn't. No rounds, no block; unreadable, written as before. - Docs say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…too early, and say how long ago An Improve action's first read is its baseline, and until a read is 7 days past the send its days still overlap the baseline's: every platform read "unchanged", so the next generation could take a round sent yesterday as one that did not move. - improveRound: a round whose read is less than OUTCOME_WINDOW_DAYS past its send (or has no read) gives its platforms "too_early"; each round says how many days ago it was sent, against an injectable `now`. - buildImprovePrompt: "Sent 2026-10-26, 2 days ago", "too early to read", and the "did not move" rule doesn't count those platforms. - Docs say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A skipped task read as "not done", as if it still waited, so the next generation could suggest again what the team chose not to do. - improveRound: each suggestion's status is done, skipped or not_done (failed and waiting for approval are not done). - buildImprovePrompt: "(skipped by the team)", and, when a round has one, "Do not suggest again what the team skipped." - Docs say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gestions each, one line apiece A round's every task went into the prompt as typed: a long round, a title edited over several lines, or one with its own double quotes could swell the prompt or break its quoted list. - improveRound: a round's first 12 titled suggestions in task order (IMPROVE_ROUND_TASKS), each title's line breaks and runs of spaces read as one space. - buildImprovePrompt: a title's double quotes are written as single ones inside its quotes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…region An Improve set is kept per region and its action keeps that region, but the earlier rounds were read for every region: a US set could be told how a German round moved. - loadImproveRounds takes the set's region: a region reads the actions sent with it (payload->>region), '' or none reads those sent without one, as they are measured over all regions. - POST /:promptId/improve passes the request's region. - Docs say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st's logger
The route logs on req.log everywhere else; the earlier-rounds warning used
the module logger and only the error's message.
- POST /:promptId/improve: req.log.warn({ err, promptId }, …), and the
logger import goes.
- Route test: the set's region's earlier rounds reach the model's prompt,
and when they can't be read the suggestions are still written, with the
warning on the request's log.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sk read and errors The supabase stub dropped order() and limit(), so nothing held the read to the newest two rounds, and the action_tasks read and the error branches went untested. - The stub records order and limit and can return an error per table. - loadImproveRounds: newest first, limit 2, the tasks read by those actions' ids in position order and grouped per round; an unreadable actions or action_tasks read throws with what failed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
Own change. c0cee01 through 8ade052 on 3f6a4d4. Server and docs only. It merges cleanly on main (b591947), and with #1687–#1689 and #1698 squashed before it; main's change to /from-topics in prompts.js sits apart from this one.
Checked
- Scope. The brand comes from the prompt's own set after
assertBrandAccess, and both reads filter by that brand (actions) or by the ids those returned (tasks). No other brand's rounds can reach the prompt. - Region. The send stores
region: set.region || null, and the read useseq('payload->>region', region)oris(..., null)for no region; an empty string from the range reads as no region on both sides. Actions sent beforeregionwas in the payload read as no region too, which is how they're measured. - Too early. A round whose last read is under
OUTCOME_WINDOW_DAYSfrom the send reads "too early to read" on every platform, and the rule tells the model not to count those as not moving. - Cost and failure. The read runs only after the budget is reserved and the model will be called. A failed read logs on
req.logand the generation goes on without history; the route test pins one model call and a 200. - Speed. The two regexes (
\s+and") are linear: 24 titles of 200 KB each (whitespace runs and quotes) build the prompt in about 180 ms. - Tests. On this PR's tree, the three files pass (47). With main's
from-prompt-improve.js,prompt-improve.jsandprompts.jsput back, 12 fail.
Follow-ups
- Cap each title. Titles go into the prompt in full (
from-prompt-improve.js:167). The app cuts a task title at 200 characters when it's added or edited, butaction_tasks.titlehas no limit of its own, so a long title written another way makes each later Improve call bigger, and it's charged by tokens. Cutting it at 200 characters here, at a word, bounds the block to 2 × 12 lines.
Before the API deploy. Nothing changes. It's server-only; the guide's new paragraph goes out with the docs before the API does.
Merged
7 of 12 tasks
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
Agentic learning, B5 part 2: Improve sees the brand's earlier Improve rounds on the same prompt.
Improve (PROMPT-008) wrote its suggestions without knowing what was tried before on that prompt, or what came of it.
loadImproveRounds({ promptId, brandId, region })(from-prompt-improve.js) reads the brand's last 2prompt_improveactions on this prompt.payload->>promptId, not dismissed, not deleted, same brand, and the request's region.Each round (
improveRound) carries:position_outcome, and whether the reading is final;buildImprovePrompt({ …, history })adds an "Earlier Improve rounds on this prompt" block with these rules:No rounds means no block.
Pre-push review fixes:
OUTCOME_WINDOW_DAYS(7) after it was sent reads "too early to read" for its platforms. Its "did not move" rule doesn't apply. Before, a round sent two days ago read "unchanged", and the model could take that as a failure.req.log.warn, keeping the request id.prompts-improve-generate.test.js: when history can't be read, Improve still answers 200 and calls the model once.Safety:
assertBrandAccess. The query filters by brand and prompt, so no other brand's rounds are read./improvestays blocked for an ended plan (fix(server): return a workspace's stored data on reads while its plan has ended, bound setup suggestions without a plan, and name billing's open writes #1611).Where people see it: Prompts › a prompt's "…" › Improve position… › Improve: the suggestions generated there. On a prompt with an earlier Improve action, a suggestion that didn't move its platform isn't offered again. No new button. Cost: the same model call, with a few more lines of prompt.
Related issue
Agentic learning report, phase B (B5). No GitHub issue. Learning stays within one brand.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/action-center/from-prompt-improve.test.js src/lib/prompt-improve.test.js src/routes/prompts-improve-generate.test.jsThe region filters (
payload->>regionequal to a region, or null) were run read-only against the dev database: PostgREST accepts both.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Server checks at 8ade052:
npm test(noSUPABASE_*env, as in CI): 3,350 tests passed.content-people.test.jsandcontent-agent.test.js(budgets of 150 ms and 400 ms) ran over while another full check was running (load average 18). This branch doesn't touch either file; both passed in the earlier runs of this batch.The web is unchanged (docs only).
🤖 Generated with Claude Code