code-yeongyu / code-yeongyu/oh-my-openagent

[Feature]: make read_session tool able to read at offset and/or an agents last message

Open
#802 4 comments 1 reaction 1 assignee Claimed by @code-yeongyu View on GitHub
enhancement triage:feature-request
Dominant language
TypeScript
Stars
69k
Forks
5.7k
Avg merge
3h 2m
Merged PRs (30d)
620

Description

### Prerequisites

- [x] I have searched existing issues and discussions to avoid duplicates
- [x] This feature request is specific to oh-my-opencode (not OpenCode core)
- [x] I have read the [documentation](https://github.com/code-yeongyu/oh-my-opencode#readme)

### Problem Description

The read_session tool can read the entire session, or return a number of messages, but cannot read offsets or the last message in the session. This prevents using the read_session tool to let one agent gain context from subagents responses without reading the entire subagent session.

This becomes a problem in OpenCode builds where subagent to subagent tasking and persistent sessions are used. I introduced a PR to OpenCode with that feature (https://github.com/anomalyco/opencode/pull/7756#issuecomment-3734080778).

### Proposed Solution

Update the read_session tool to allow offset reads or reading the last message in a session.

### Alternatives Considered

Instruct the Primary agent to use it's in-context memory of subagent responses to write files which it then instructs subagents to read (relay-files). Presumably, writing files from existing text-in-context is less straining on the context window then generating text to send in prompts to subagents via A2A.

### Doctor Output (Optional)

```shell

```

### Additional Context

The read_session tool having offset reads or last message reads would be generally beneficial. However, it is especially beneficial when subagents can task subagents and maintain persistent sessions.

An example of a subagent-subagent persistent session workflow.

A Primary agent tasks a substantive-work subagent to extract and consolidate data from a corpus in stages. The substantive-work subagent produces multiple consolidated documents. The Primary agent sends one of the documents to be reviewed by a group of review-agents. The review-agents return responses to the Primary. The Primary reports to the user a summary of review-agents findings.

The substantive-work subagent can then be tasked to receive the review-agents responses, but the Primary would have to waste context generating text to relay messages from the review-agents to the substantive-work subagent. Being able to instruct the substantive-work subagent to read the last message in review-agents sessions would efficiently relay responses/data. The substantive-work subagent could then use that data, and it's prior context (it's a persistent session) to determine if the review-agents findings are true, and if so, issue corrections to the document.

Alternative workflow with stateless sessions:

Primary agent tasks to review a corpus of data by tasking multiple subagents. All subagents return response. Primary then instructs on subagent to read_session for all subagent sessions and use that distilled data to perform a task.

**This feature is critical to agentic workflows performing data extraction, transformation, and consolidation; to knowledge-work.**

### Feature Type

New Tool

### Contribution

- [x] I'm willing to submit a PR for this feature
- [x] I can help with testing
- [x] I can help with documentation

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.