Skip to content

Conversation

@enyst
Copy link
Collaborator

@enyst enyst commented Nov 9, 2025

Summary

  • Implement explicit /condense user command handling in LocalConversation.send_message
  • Leverage skills system: activation of a skill named "condense" also triggers condensation
  • Emit CondensationRequest event and return early (no user MessageEvent) to let condenser act next run
  • Add comprehensive unit tests for the flow
  • Provide runnable example using Gemini 2.5 Pro condenser

Changes

  1. LocalConversation
  • Detect "/condense" in user message text content OR activation of a knowledge skill named "condense"
  • When detected, emit CondensationRequest() and return, leaving the next run() to process condensation via configured condenser
  1. Tests
  • tests/sdk/conversation/local/test_condense_command.py
    • test_send_message_with_slash_condense_emits_request: ensures CondensationRequest is emitted and no MessageEvent is recorded for that call
    • test_condense_request_triggers_condenser_on_next_step: with LLMSummarizingCondenser configured, verifies a Condensation event appears after run()
    • test_condense_skill_trigger_name: activating a skill named "condense" also emits CondensationRequest
  1. Example
  • examples/01_standalone_sdk/15_condense_command.py
    • Demonstrates explicit /condense command and skill-triggered condensation
    • Uses model gemini-2.5-pro with GEMINI_API_KEY from environment

Motivation
This PR implements the user-facing /condense command requested in issue #8276, aligning with the existing condenser flow (LLMSummarizingCondenser) and skills architecture. It allows users to explicitly request context condensation, especially useful with an LLM summarizer condenser.

How it works

  • On send_message(), we first allow per-turn skill activation (to collect activated_skill_names)
  • If a skill named "condense" is activated or the message includes "/condense", we emit CondensationRequest and exit
  • On the next run(), the condenser notices the unhandled request and performs condensation, optionally injecting a CondensationSummaryEvent into the view

Testing

  • Added focused tests; they pass locally:
    • uv run pytest tests/sdk/conversation/local/test_condense_command.py
  • Ran pre-commit hooks on changed files (ruff format/lint, pyright): passed

Docs/Examples

  • Included a standalone example using Gemini 2.5 Pro. To run:
    GEMINI_API_KEY=... uv run python examples/01_standalone_sdk/15_condense_command.py

Notes

  • This change is backward-compatible; only adds a conditional shortcut for /condense
  • The example uses gemini-2.5-pro; ensure appropriate API key is set in env

Closes #8276

@enyst can click here to continue refining the PR


Agent Server images for this PR

GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.12-nodejs22 Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:1f398f0-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-1f398f0-python \
  ghcr.io/openhands/agent-server:1f398f0-python

All tags pushed for this build

ghcr.io/openhands/agent-server:1f398f0-golang-amd64
ghcr.io/openhands/agent-server:1f398f0-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:1f398f0-golang-arm64
ghcr.io/openhands/agent-server:1f398f0-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:1f398f0-java-amd64
ghcr.io/openhands/agent-server:1f398f0-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:1f398f0-java-arm64
ghcr.io/openhands/agent-server:1f398f0-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:1f398f0-python-amd64
ghcr.io/openhands/agent-server:1f398f0-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:1f398f0-python-arm64
ghcr.io/openhands/agent-server:1f398f0-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:1f398f0-golang
ghcr.io/openhands/agent-server:1f398f0-java
ghcr.io/openhands/agent-server:1f398f0-python

About Multi-Architecture Support

  • Each variant tag (e.g., 1f398f0-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 1f398f0-python-amd64) are also available if needed

…tionRequest in LocalConversation; add tests and example

- Detect '/condense' in user text or activation of a 'condense' skill
- Emit CondensationRequest and return early (no user MessageEvent)
- Add unit tests covering command, condenser integration, and skill trigger
- Provide example script using Gemini 2.5 Pro condenser

Closes #8276

Co-authored-by: openhands <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/conversation/impl
   local_conversation.py1895371%121, 123–124, 157–158, 181, 186, 198, 215, 223–225, 229–230, 238–239, 291–292, 295, 302, 323–325, 328, 337, 353, 355, 357, 361, 363–365, 367, 369, 375–376, 389–390, 392, 394, 398–401, 419, 424, 426, 431, 433–435, 453, 455
TOTAL11805543054% 

@openhands-ai
Copy link

openhands-ai bot commented Nov 9, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Check Documented Examples

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1114 at branch `openhands/condense-command-skill`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@enyst enyst marked this pull request as draft November 9, 2025 01:35
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.

2 participants