[Feature]: Entity-preserving context condensation (anchor retention for exact IDs, hashes, and redacted values)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- ai-infra-agents, backend-api-design, testing
Research direction
Read openhands-sdk/openhands/sdk/context/condenser/prompts/summarizing_system.j2, LLMSummarizingCondenser._build_summary_messages, and CondensationSummaryEvent.to_llm_message(); inspect Condensation and tests under tests/sdk/context/condenser/. Run the condenser unit tests first, then check event serialization and the TypeScript schema mirror. Done means the prompt preserves exact literals, the replacement message identifies the forgotten event span, and optional size metadata is covered by tests. An open linked pull request (#6998) is already addressing this issue.
Written by the indexing model from the issue text.
Description
Is there an existing feature request for this?
- I have searched existing issues and feature requests, and this is not a duplicate.
Problem or Use Case
During long-horizon tasks with large file reads, LLM-based condensation summarizes evicted turns into prose. While high-level task intent survives, exact load-bearing literals observed only in evicted turns (such as certificate thumbprints, SHA digests, ISO timestamps, ticket IDs, or pre-redaction audit values that were intentionally removed from workspace files) are routinely paraphrased or dropped by the summarizer.
In our evaluation on TraceTrial-Bench (arXiv:2610.32285, mechanism node C2 — C2-cert-rotation-redaction-001 & C2-depbump-redaction-002), OpenHands triggered native condensation as expected (hr_native_compaction_after_pressure passed), but 0/6 exact suffix/timestamp values survived in the active summary (hr_active_summary_preserved_sensitive_details=False), directly causing downstream deliverable failures (harness_caused).
Desired Behavior
Enhance the SDK condenser (LLMSummarizingCondenser / Condensation) with entity-anchor preservation:
- Update the condensation prompt and/or pre-extraction pass to explicitly preserve exact identifiers, hashes/thumbprints, timestamps, numeric totals, file paths, and anomaly/task IDs encountered in forgotten events inside a structured
<preserved_facts>/ key-value block within the summary. - Expose condensation metadata on the
Condensationevent (e.g. range of condensed event IDs and character/token counts before vs. after) so the agent knows exact history boundaries were summarized rather than silently vanished.
Acceptance Criteria
-
LLMSummarizingCondenserpreserves exact load-bearing identifiers, digests, timestamps, and numeric figures from condensed events in a dedicated structured section of the summary - Model-visible condensation notice clearly indicates the condensed turn/event span
- Unit and benchmark regression tests verify exact literal survival across condensation boundaries
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Scope (verified against the repository): the summarization instructions live in openhands-sdk/openhands/sdk/context/condenser/prompts/summarizing_system.j2, rendered by LLMSummarizingCondenser._build_summary_messages; the model-visible replacement for forgotten events is CondensationSummaryEvent.to_llm_message() (currently a plain user message with no span indication); and the Condensation event already carries forgotten_event_ids and summary_offset. The work is therefore bounded to: (1) extending the rendered summarization prompt so it requires a dedicated structured section (e.g. <preserved_facts>) holding exact load-bearing literals from the summarized events, (2) making the model-visible summary state the condensed span, and (3) recording before/after size metrics on Condensation as optional fields.
Priority: medium. The issue records a reproduced failure of the real condensation workflow (a public TraceTrial-Bench run where native condensation preserved 0/6 measured literals and downstream deliverables failed), which meets the medium bar of a reproduced failure in the actual product/workflow; there are no user support reports or production incidents, so not high.
Non-goals: no deterministic pre-extraction/regex entity pass (prompt-level preservation first; revisit only if shown insufficient); no changes to NoOpCondenser, PipelineCondenser, or condenser sizing defaults (max_size/keep_first); no integration of TraceTrial-Bench into this repository; no changes to secret redaction (existing pydantic_secrets handling untouched). Note: literal survival through an LLM summarizer is stochastic, so the deterministic gates are the rendered-prompt instructions plus the repo's real-LLM condenser integration tests, not a hard "every literal survives" assertion.
Acceptance Criteria
- The rendered summarization prompt sent to the condenser LLM instructs preserving exact load-bearing literals from the summarized events (identifiers, hashes/thumbprints, timestamps, numeric totals, file paths, and ticket/anomaly IDs) in a dedicated structured section of the summary.
- After condensation, the user-role message the LLM sees in place of forgotten events states that a condensation occurred and identifies the span it replaces (e.g., the number or range of condensed events).
- The
Condensationevent records before/after size metrics for the condensed span (character counts before vs. after, plus token counts where a token count is available) as optional fields with defaults, alongside the existingforgotten_event_ids. - Old persisted events still load:
Condensationpayloads without the new fields and existingCondensationSummaryEventpayloads deserialize and apply to views unchanged, pertests/sdk/event/test_event_serialization.py. - Unit tests under
tests/sdk/context/condenser/using the existing mocked-LLM fixture verify the rendered prompt instructions, the new metadata, and the span notice in the model-visible message; existing condenser unit tests still pass. - The new optional
Condensationfields appear in the agent-server OpenAPI schema and the regeneratedclients/typescript/mirror. - The PR adds the
integration-testlabel so the real-LLM condenser integration tests (tests/integration/tests/c02_hard_context_reset.py,c05_size_condenser.py) run against the updated summarization prompt and pass.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 797
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 354
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenHands/software-agent-sdk
-
[Bug]: `list_directory` reports a complete listing as truncated when a directory has exactly 500 entriesPossibly taken @balabommablock-cpu claimed this 29 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
OpenHands/software-agent-sdk#6133 ·
Maintainers usually reply within 1 day
-
[Bug]: Command hook that exits 1 is treated as blocking when its stdout is a JSON `deny` or `continue: false`Possibly taken A pull request linked to this issue is open or already merged. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/software-agent-sdk#6116 · 3 comments ·
Maintainers usually reply within 1 day
-
[Bug]: TypeScript GET-with-body requests remain pending after a truncated responsePossibly taken @BlueRaddish claimed this 34 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
OpenHands/software-agent-sdk#6059 ·
Maintainers usually reply within 1 day
-
[Bug]: Document whether `prompt_tokens` includes `cache_read_tokens` in accumulated token usagePossibly taken @Jaxon1216 claimed this 36 days ago. Openpriority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5975 ·
Maintainers usually reply within 1 day
-
priority:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5708 · 1 comment ·
Maintainers usually reply within 1 day
All issues in OpenHands/software-agent-sdk
Similar issues
-
[Bug]: reme CLI crashes when the running server used a relative config pathPossibly taken @nurlanmnn claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/ReMe#770 ·
Maintainers usually reply within 1 day
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionPossibly taken @balcsida claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/TokenEconomizer#288 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 67/100
sickn33/agentic-awesome-skills#2437 ·
Maintainers usually reply within 1 day
-
site-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ethereum/consensus-specs#5846 ·
Maintainers usually reply within 1 day