Skip to content

Harden autopilot steers against prompt injection; fix scrollback flush flash#294

Merged
yanmxa merged 2 commits into
genai-io:mainfrom
yanmxa:feat/autopilot-steer-hardening
Jul 10, 2026
Merged

Harden autopilot steers against prompt injection; fix scrollback flush flash#294
yanmxa merged 2 commits into
genai-io:mainfrom
yanmxa:feat/autopilot-steer-hardening

Conversation

@yanmxa

@yanmxa yanmxa commented Jul 10, 2026

Copy link
Copy Markdown
Member

Two unrelated changes, bundled at author request (see the two commits).

Autopilot steer hardening

Guards the autopilot LLM steers (Permission, Bash, Question, turn-end
continue) against prompt injection from untrusted content:

  • Composes each steer's system prompt as an immutable control-plane policy
    plus the user's steering instructions — policy in the recency slot, forged
    </steering_instructions> delimiters stripped — so a shared preset or
    systemPromptFile can't weaken the trust boundaries.
  • Routes all untrusted payloads (tool args, transcripts, questions, bash
    prompts) through one JSON data envelope (reviewer.RenderDataEnvelope);
    json.Marshal escapes <, >, &, so values can't forge the delimiters.
  • Sanitizes bash-prompt answers to a single bounded line and validates the
    continue/done/stop decision as a strict state machine.
  • Renames the user-facing "System Prompt" to "Steering Prompt".

Scrollback flush fix

Removes the blank-frame flash at the end of a streamed render by keeping a
committed block visible in the managed view until its tea.Println into
native scrollback has been processed; monotonic ids keep concurrent handoffs
ordered.

@san-ci

san-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[PR TITLE LINT] PR title does not follow Conventional Commits format.

Please update your PR title to follow Conventional Commits format:

type(scope): description

Allowed types:
feat | fix | docs | style | refactor | perf | test | build | ci | chore | revert

Examples:

feat: add user login
fix(api): handle null response
docs: update readme
refactor: extract auth middleware

You can edit the title at the top of this PR.

@san-ci

san-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[REVIEW NOTIFIER] This PR requires a review from @ldpliu.

Once this PR has been reviewed and has the lgtm label, it will be automatically squash-merged.

Suggested reviewer

Based on OWNERS, @ldpliu is suggested to review this PR.

How to get your PR reviewed:

  • Address reviewer feedback and push changes
  • Reviewer adds lgtm label when satisfied
  • An approving review + lgtm will trigger auto-merge

@san-ci

san-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[REBASE NOTIFIER] Hi @yanmxa! This PR has merge conflicts.

The lgtm label has been removed and the reviewer will need to re-review after you fix this.

How to fix this

resolve the conflicts — Fix the merge conflicts locally, then push the resolved changes.

After fixing:

  • The need-rebase label will be automatically removed
  • Request a new review from the OWNERS file
  • The reviewer can add lgtm once satisfied

yanmxa added 2 commits July 10, 2026 09:48
Harden the autopilot steers (Permission, Bash, Question, turn-end
continue) against prompt injection from untrusted content:

- Compose every steer's system prompt as an immutable control-plane
  policy plus the user's steering instructions, with the policy in the
  recency slot and forged <steering_instructions> delimiters stripped, so
  a shared preset or systemPromptFile can't weaken the trust boundaries.
- Render untrusted payloads (tool args, transcripts, questions, bash
  prompts) as JSON data envelopes through one shared
  reviewer.RenderDataEnvelope; json.Marshal escapes <, >, & so payload
  values can't forge the delimiters.
- Sanitize bash-prompt answers to a single bounded line and validate the
  turn-end continue/done/stop decision as a strict state machine.
- Feed recent tool results and compact summaries into the continue
  decision's evidence window, with a tighter per-tool-result cap.
- Rename the user-facing "System Prompt" to "Steering Prompt" to reflect
  that it tunes how the copilot drives without replacing the policy.

Signed-off-by: Meng Yan <yanmxa@gmail.com>
Replace the fixed print delay (which briefly left a just-committed block
in neither the live view nor native scrollback — the blank-frame flash at
the end of a render) with a handoff copy kept in the managed view until
the block's tea.Println has been processed. Monotonic ids keep concurrent
handoffs ordered.

Signed-off-by: Meng Yan <yanmxa@gmail.com>
@yanmxa yanmxa force-pushed the feat/autopilot-steer-hardening branch from 12e4ab5 to b2d609b Compare July 10, 2026 05:27
@san-ci san-ci Bot removed the need-rebase label Jul 10, 2026
@yanmxa yanmxa merged commit e02ed42 into genai-io:main Jul 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant