Thread Goal
July 16, 2026 ยท View on GitHub
Persistent thread goals for MindRoom agents that survive context compaction.
When agents work on long tasks, conversation history gets compacted to save tokens. Important context can disappear. Thread Goal stores a short shared goal string in Matrix room state and re-injects it into every prompt, so the agent keeps the same objective no matter how many turns, restarts, or compaction passes happen afterward.
Features
- Stores a short thread goal in Matrix room state under
com.mindroom.thread.goal - Re-injects the goal into every prompt via
message:enrich - Persists across compaction, restarts, and long-running threads
- Exposes dedicated thread-scoped tools to set, read, and clear the goal
- Records
set_byandset_atmetadata alongside the goal text - Enforces a normalized 160-character limit so the stored goal stays compact
How It Works
- An agent calls
set_thread_goal(goal)in the active thread. - The plugin stores the normalized goal as a Matrix state event keyed by the thread root event ID.
- On each turn, the
thread-goal-contexthook reads the current goal from room state. - If a goal exists, the hook injects a stable
Thread goal: ...enrichment item into the prompt.
Agent Tools
| Tool | Purpose |
|---|---|
set_thread_goal(goal) | Set or update the current thread goal. Maximum length: 160 characters |
get_thread_goal() | Read the current thread goal and its metadata |
clear_thread_goal() | Clear the current thread goal |
All three tools are thread-scoped only. They refuse to operate at room level.
Hooks
| Hook | Event | Purpose |
|---|---|---|
thread-goal-context | message:enrich | Inject the current thread goal into the prompt before workloop runs |
Storage
- Event type:
com.mindroom.thread.goal - State key: the thread root event ID
- Payload fields:
goal,set_by,set_at - Clearing the goal writes an empty payload for that state key
Install
Vendor this plugin with the MindRoom CLI:
mindroom plugins install thread-goal-plugin
Then reference it from config.yaml:
plugins:
- path: plugins/thread-goal-plugin
Update to the latest commit later with:
mindroom plugins update thread-goal-plugin
The command pins the exact installed commit in .mindroom-plugin.lock.json and strictly validates the plugin before activating it.
For a manual checkout instead, see Setup below.
Setup
- Copy this plugin to
~/.mindroom/plugins/thread-goal. - Add the plugin to
config.yaml:plugins: - path: plugins/thread-goal - Add
thread_goalto the agent's tools list. - Restart MindRoom.
Complements workloop: thread-goal is what the agent is trying to achieve, and workloop is how it gets there.