Generate system instructions from chat history - #403
Open
gyanu2507 wants to merge 8 commits into
Open
Conversation
gyanu2507
requested review from
bhaveshpatel640,
chiragjn,
debajyoti-truefoundry,
govindavashishtha,
heerambavi1998,
kumarsks619,
qaifi-tf,
sajal-truefoundry,
sayan-truefoundry,
sr07asthana and
vinit-truefoundry
as code owners
August 22, 2026 10:28
🦋 Changeset detectedLatest commit: 243929c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
gyanu2507
force-pushed
the
feat/generate-instructions-from-chat
branch
from
August 22, 2026 15:40
b3f5f6a to
5e08c13
Compare
gyanu2507
force-pushed
the
feat/generate-instructions-from-chat
branch
from
August 24, 2026 10:07
c7fe4cd to
9f22d41
Compare
Users can promote a working conversation into an editable draft instead of writing the agent prompt from scratch, and nothing is saved until they apply or copy it. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Walk a turn's user messages newest-first so the transcript reverse keeps them in order.
gyanu2507
force-pushed
the
feat/generate-instructions-from-chat
branch
from
August 24, 2026 11:06
9f22d41 to
0672b2f
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 74e33f4. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Fixes #357
System instructions currently have to be written from scratch, even when the chat already made it obvious how the user wants the agent to behave.
This adds a From chat button on the session header. It drafts instructions from the transcript, you can edit them in a dialog, and nothing is saved until you apply. Inline chats can apply the draft to that session. Named/registry agents only get copy, so we don't mutate the saved agent.
Short chats return 422 before we call the model, so a "hey"/"hi" conversation doesn't turn into a generic helpful-assistant prompt.
New route:
POST /api/v1/sessions/{session_id}/generate-instructionsIt only returns a suggestion (
instructions,current_instructions,sources). Saving still goes through the existing session update.I didn't regenerate the SDK. The UI adapter hits the new path with
client.fetch.Note
Medium Risk
New authenticated session endpoint invokes the session model on transcript data and updates agent specs on apply; mistakes could affect future turns, though drafts are explicit and short chats are gated.
Overview
Adds From chat in the session header so users can infer system instructions from the transcript, edit them in a modal, and only persist when they choose Apply (inline/mutable sessions). Named registry-bound chats get Copy only so saved agents are not mutated server-side.
Backend exposes
POST /api/v1/sessions/{session_id}/generate-instructions, which returns a draft (instructions,current_instructions,sources) without writing the session. Transcript extraction skips subagent threads; 422 is returned when user text is too thin before any LLM call, and model output is filtered to block generic one-liners. The harness UI adapter calls the new route viaclient.fetch; saving still uses the existing session update path after flush/adopt.Reviewed by Cursor Bugbot for commit 243929c. Bugbot is set up for automated code reviews on this repo. Configure here.