Skip to content

feat(rskim-llm): OpenAI body mutation (list_blocks / mutate_block) — follow-up to #302 #332

Description

@dean0x

Context

rskim-llm (#302) ships Anthropic body mutation via list_blocks / mutate_block (byte-surgery text-for-text replacement). OpenAI /v1/chat/completions bodies are parsed and classified, but mutation is not yet implemented:

  • list_blocks(ParsedBody::OpenAi(_)) returns an empty Vec.
  • mutate_block on an OpenAI body returns LlmError::BlockNotMutable(id, "openai-not-implemented").
  • classify_body does walk OpenAI content and emits ids of the form m{i} / m{i}p{j}, but those ids are not addressable through list_blocks / mutate_block (documented asymmetry in lib.rs).

Scope

Implement OpenAI text-payload mutation symmetric with the Anthropic path:

  • Byte-surgery splice for OpenAI string content (messages[i].content string) and content-part text (messages[i].content[j].text where type == "text").
  • Keep the no-envelope-mutation invariant absolute (Resolved Decision 7): model, tool_calls, tool_call_id, reasoning, function.arguments remain sacrosanct / exempt (Resolved Decision 6).
  • list_blocks returns mutable descriptors for OpenAI bodies; ids align with classify_body.
  • Round-trip byte-identity + repeat-mutation idempotency tests mirroring the Anthropic suite.

Note

Tracked because the source previously referenced a wrong issue number (#329 is a rskim-tokens follow-up). This is the correct tracker (ADR-004: follow-ups filed and correctly linked, no orphaned refs / AC18).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions