Skip to content

fix(compact): keep rewritten current-turn messages after compaction - #854

Open
mkoushni wants to merge 6 commits into
praxis-proxy:mainfrom
mkoushni:fix/661-compact-preserve-resolved-input
Open

fix(compact): keep rewritten current-turn messages after compaction#854
mkoushni wants to merge 6 commits into
praxis-proxy:mainfrom
mkoushni:fix/661-compact-preserve-resolved-input

Conversation

@mkoushni

@mkoushni mkoushni commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Compaction rebuilt the current turn from immutable state.input, which file resolve and document extract never update. After a file_url fetch, that restored the original URL on the outbound body and bypassed resolver SSRF checks. The same path restored input_file after extraction.
  • replace_messages now keeps the already-rewritten tail of messages / persisted_messages (last state.input.len() items) instead of cloning state.input.
  • The compact example runs file_resolve and doc_extract before compact so that composition is covered end-to-end.

Fixes #661

Test plan

  • cargo test -p praxis-ai-apis --lib compact
  • cargo test -p praxis-tests-integration --test suite compact
  • cargo clippy -p praxis-ai-apis --lib --tests -- -D warnings
  • make lint

…raxis-proxy#661)

File resolve and doc extract rewrite the messages tail in place and leave
state.input as the original client payload. Rebuild that tail from messages
instead of cloning input so resolved file_data and extracted text survive.

Signed-off-by: mkoushni <mkoushni@redhat.com>
…-proxy#661)

Assert the compact example pipeline keeps resolved file_data and
extracted input_text on the current turn, and that the serialized
proxy body never restores file_url or file_id.

Signed-off-by: mkoushni <mkoushni@redhat.com>
@mkoushni
mkoushni requested review from a team and jland-redhat September 1, 2026 11:34
clippy::unused_async fails make lint because the helper never awaits.
Signed-off-by: mkoushni <mkoushni@redhat.com>

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Summary: The fix correctly preserves rewritten current-turn messages during compaction by splitting the tail of each message list rather than rebuilding from the immutable state.input. Logic is sound and test coverage is thorough.

Overall: Solid fix. Two convention cleanups needed.

Severity Count
Critical 0
Large 0
Medium 2

Comment thread apis/src/openai/responses/compact/tests.rs Outdated
Comment thread apis/src/openai/responses/compact/tests.rs Outdated
Function names and assertion messages already carry the intent;
CONTRIBUTING forbids documenting tests with /// or body comments.

Signed-off-by: mkoushni <mkoushni@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction restores stale file references after resolution, bypassing the protected rewrite

2 participants