[GH-ISSUE #536] [Feature]: Add agent tool calls for chat-wide variables #246

Closed
opened 2026-10-20 17:26:44 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @cha1latte on GitHub (May 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/536

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

Agents do not currently have a built-in way to read and write arbitrary chat-wide state through tool calls.

The recently added read and append chat summary tool calls provide a related pattern, but they only write to the summary and do not support replacing arbitrary named values. The reporter currently sees the only workaround as creating a separate server with state logic and connecting it through a custom webhook tool call, unless script-type tools can persist data in a way they are unaware of.

This limits custom agents that need to keep internal chat-wide state, coordinate with other agents, or leave messages for each other using predefined keys.

Proposed solution

Add two new tool calls that allow agents to manage custom chat-wide variables:

  • A write tool call that writes string content to a variable identified by a string key.
  • A read tool call that reads the variable content by the same string key.

The write behavior should probably replace the existing value by default. An append option would make the system more flexible, either as a user-configurable option or as a choice available to the agent when calling the write tool.

The primary desired behavior is a chat-wide String -> String map where:

  • The key is the variable name.
  • The value is the stored string content.
  • Any agent in the chat can read a variable if it knows the key.
  • Agents can use the variables to maintain private/internal state or communicate with other agents.

A UI that lets the user inspect and manually edit the current variables and values would also be helpful, but is not required for the first version.

Alternatives considered

  • Use the existing read and append chat summary tool calls. This is too limited because it only writes to the summary and does not provide arbitrary named variables or replace behavior.
  • Create a separate server with state logic and attach it through a custom webhook tool call. This can work, but it is much heavier than a built-in chat-wide variable store.
  • Expand the existing custom tracker system. The reporter notes this may overlap conceptually, but trackers feel more user/character-facing, while the desired variables are more agent-internal and technical.
  • Create a more general variable system that can support both trackers and agent variables. This may be more flexible, but could be too much work for the first version.

Additional context

Discord report: https://discord.com/channels/1417099416812392641/1502059754627797152

Reported by s'nt.

The main goal is to allow agents to read and write private chat-wide variables at will through tool calls.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @cha1latte on GitHub (May 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/536 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? Agents do not currently have a built-in way to read and write arbitrary chat-wide state through tool calls. The recently added read and append chat summary tool calls provide a related pattern, but they only write to the summary and do not support replacing arbitrary named values. The reporter currently sees the only workaround as creating a separate server with state logic and connecting it through a custom webhook tool call, unless script-type tools can persist data in a way they are unaware of. This limits custom agents that need to keep internal chat-wide state, coordinate with other agents, or leave messages for each other using predefined keys. ## Proposed solution Add two new tool calls that allow agents to manage custom chat-wide variables: - A write tool call that writes string content to a variable identified by a string key. - A read tool call that reads the variable content by the same string key. The write behavior should probably replace the existing value by default. An append option would make the system more flexible, either as a user-configurable option or as a choice available to the agent when calling the write tool. The primary desired behavior is a chat-wide `String -> String` map where: - The key is the variable name. - The value is the stored string content. - Any agent in the chat can read a variable if it knows the key. - Agents can use the variables to maintain private/internal state or communicate with other agents. A UI that lets the user inspect and manually edit the current variables and values would also be helpful, but is not required for the first version. ## Alternatives considered - Use the existing read and append chat summary tool calls. This is too limited because it only writes to the summary and does not provide arbitrary named variables or replace behavior. - Create a separate server with state logic and attach it through a custom webhook tool call. This can work, but it is much heavier than a built-in chat-wide variable store. - Expand the existing custom tracker system. The reporter notes this may overlap conceptually, but trackers feel more user/character-facing, while the desired variables are more agent-internal and technical. - Create a more general variable system that can support both trackers and agent variables. This may be more flexible, but could be too much work for the first version. ## Additional context Discord report: https://discord.com/channels/1417099416812392641/1502059754627797152 Reported by s'nt. The main goal is to allow agents to read and write private chat-wide variables at will through tool calls. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:26:44 +07:00
Author
Owner

@cha1latte commented on GitHub (May 7, 2026):

Triage note: labeling this as scope-risk because the request is well aligned with agent tool workflows, but it introduces persistent chat-wide state and overlaps with existing tracker/summary concepts that need a clear boundary before implementation.

Define the smallest shippable version as read/replace string variables for one chat scope before adding append behavior or a manual variable editor.

<!-- gh-comment-id:4401686534 --> @cha1latte commented on GitHub (May 7, 2026): Triage note: labeling this as `scope-risk` because the request is well aligned with agent tool workflows, but it introduces persistent chat-wide state and overlaps with existing tracker/summary concepts that need a clear boundary before implementation. Define the smallest shippable version as read/replace string variables for one chat scope before adding append behavior or a manual variable editor.
Author
Owner

@SpicyMarinara commented on GitHub (May 10, 2026):

Will add tools, skip the UI parts for now.

<!-- gh-comment-id:4414979348 --> @SpicyMarinara commented on GitHub (May 10, 2026): Will add tools, skip the UI parts for now.
Author
Owner

@SpicyMarinara commented on GitHub (May 10, 2026):

Implemented in the local v1.5.9 issue sweep.

  • Added read_chat_variable and write_chat_variable built-in agent tools.
  • Variables are stored as a chat-scoped string map in chat metadata under agentVariables.
  • Writes replace the existing value for a key; no UI editor or append behavior was added for this first version.
  • Kept these tools agent-only so they are not exposed to the main chat tool list.
  • Added retry-agent metadata tool context support for these chat metadata tools.
  • Added the release note to CHANGELOG.md.

Validation:

  • pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/tool-executor-agent-variables.test.ts
  • pnpm --filter @marinara-engine/server lint.
<!-- gh-comment-id:4415089615 --> @SpicyMarinara commented on GitHub (May 10, 2026): Implemented in the local v1.5.9 issue sweep. - Added `read_chat_variable` and `write_chat_variable` built-in agent tools. - Variables are stored as a chat-scoped string map in chat metadata under `agentVariables`. - Writes replace the existing value for a key; no UI editor or append behavior was added for this first version. - Kept these tools agent-only so they are not exposed to the main chat tool list. - Added retry-agent metadata tool context support for these chat metadata tools. - Added the release note to `CHANGELOG.md`. Validation: - `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/tool-executor-agent-variables.test.ts` - `pnpm --filter @marinara-engine/server lint`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#246
No description provided.