Skip to content

[Bug]: POST /api/conversations/{id}/reactions returns the reaction with parent_id null; the stored event has its parent #6782

Description

@enyst

I'm an AI agent helping Engel Nyst (@enyst) with project work.

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

POST /api/conversations/{id}/reactions answers with the new ReactionEvent, but that copy has parent_id: null. The event the server stores and streams has the real parent_id, which is the active leaf when the reaction was recorded. The SDK has the same problem: LocalConversation.react() returns the unstamped object, while the log keeps a stamped copy.

A client that adds the POST response to its event tree, as an optimistic update does, places the reaction as a root or legacy-chained node until the socket copy arrives.

Cause: LocalConversation.react (openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py) emits the event with self._on_event(event) and returns event. ConversationState._stamp_parent_id stamps a model_copy, in both the _tree_stamping callback wrapper and append_event, so the caller keeps the original object. EventService.react and the route pass that object through unchanged.

Feature map: verify-agent-server F37.rest; the SDK twin is S16.reactions (LocalConversation.react). Both surfaces show it, because the server returns what the SDK returns.

Expected Behavior

The POST response, and the return value of LocalConversation.react(), is the event as stored, so its parent_id is the same as in search, get-one and the events socket. A reaction that is held back while a tool call waits for its result is not in the tree yet. It may keep parent_id: null until it is flushed, and the docstring should say so.

Actual Behavior

The POST response has "parent_id": null. Search, get-one and the socket frame for the same event id carry "parent_id": "ce34722e-…", the message it reacted to.

Evidence (redacted saved exchanges, main@9bf835c): [post-response.json](https://github.com/enyst/openhands-evidence/blob/5917334888ec16dc1d6a266e00073f9bebbe09ad/software-agent-sdk/bugs/2026-11-12/reaction-parent-id/post-response.json), [search.json](https://github.com/enyst/openhands-evidence/blob/5917334888ec16dc1d6a266e00073f9bebbe09ad/software-agent-sdk/bugs/2026-11-12/reaction-parent-id/search.json), [get-one.json](https://github.com/enyst/openhands-evidence/blob/5917334888ec16dc1d6a266e00073f9bebbe09ad/software-agent-sdk/bugs/2026-11-12/reaction-parent-id/get-one.json), [socket.json](https://github.com/enyst/openhands-evidence/blob/5917334888ec16dc1d6a266e00073f9bebbe09ad/software-agent-sdk/bugs/2026-11-12/reaction-parent-id/socket.json).

SDK: conversation.react("heart") returns an object with parent_id is None. The ReactionEvent in conversation.state.events with the same id has a parent.

Steps to Reproduce

On a checkout of main 9bf835c, with the verify-agent-server skill:

export PATH=$PWD/.agents/skills/verify-agent-server/scripts:$PATH
control-agent-server launch --new --name parentid-repro && control-agent-server doctor
control-agent-server api PATCH /api/settings/experimental/conversation_reactions --json '{"enabled": true}' --expect 200
CID=$(control-agent-server conversation start --no-autotitle --tools none --print-id)
control-agent-server api POST /api/conversations/$CID/events --json '{"role":"user","content":[{"type":"text","text":"QA_PID hello"}],"run":false}'
MID=$(control-agent-server api GET /api/conversations/$CID/events/search --query body=QA_PID --field items.0.id)
control-agent-server api POST /api/conversations/$CID/reactions --json '{"emoji":"heart","target_event_id":"'$MID'"}' --field parent_id     # null
control-agent-server api GET /api/conversations/$CID/events/search --query kind=ReactionEvent --field items.0.parent_id                      # $MID
control-agent-server stop

The bug was introduced together with reactions in #6609, so it is not a regression.

Acceptance Criteria

  • POST /api/conversations/{id}/reactions returns a parent_id equal to the stored event's parent_id (search, get-one, socket).
  • LocalConversation.react() returns the reaction with the parent_id it is stored with.
  • A reaction held back during a pending tool call still joins the events after the result with a parent_id, and the docstring says what the immediate return value carries.
  • A router test and an SDK test assert the returned parent_id.

Installation Method

From source

SDK Version

main@9bf835c (after v1.62.0)


Generated by Claude Code


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Confirmed on main: ConversationState._stamp_parent_id stamps a model_copy at the single storage chokepoint (append_event) and in the _tree_stamping callback wrapper, so LocalConversation.react() emits and returns the caller's original unstamped object, which EventService.react and POST /api/conversations/{id}/reactions pass through unchanged. The stored and streamed event carries the stamped parent_id while the POST response does not, so an optimistic client inserts the reaction as a root node until the socket copy arrives. This matches the reproduced evidence in the report and the F37.rest contract ("returns the saved ReactionEvent").

Scope is the return-value stamping in LocalConversation.react and any direct pass-through in EventService.react/the route, plus a docstring clarification that a reaction held back while a tool call waits for its result is not in the tree yet and may be returned with parent_id: null until it is flushed. Non-goals: no change to stamping mechanics (_stamp_parent_id, append_event, _tree_stamping), no change to the ReactionEvent schema or API shape, no change to the pending-reaction flush ordering, and no new work on the TypeScript client or Agent Canvas.

Acceptance Criteria

  • On a live agent server with the conversation_reactions feature enabled, POST /api/conversations/{id}/reactions with {"emoji", "target_event_id"} responds with a ReactionEvent whose parent_id equals the parent_id returned by GET /api/conversations/{id}/events/search and GET /api/conversations/{id}/events/{event_id} for the same event id.
  • The events socket stream for that reaction event carries the same parent_id as the POST response.
  • LocalConversation.react() returns a ReactionEvent whose parent_id equals the parent_id of the event with the same id in conversation.state.events.
  • A reaction posted while a tool call waits for its result (pending confirmation) still joins the event log after the call's result with a non-null parent_id, and the react() docstring states what the immediate return value carries for such held-back reactions.
  • A router test and an SDK-level test assert the returned parent_id matches the stored event's parent_id.

Activity

  1. added
    priority:mediumFor bugs, a serious source of annoyance, but not blocking a large number of users.
    ready-for-devIssue meets development readiness criteria
    on Nov 12, 2026
  2. added a commit that references this issue on Nov 12, 2026
    031dcf3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:mediumFor bugs, a serious source of annoyance, but not blocking a large number of users.ready-for-devIssue meets development readiness criteria

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions