Skip to content

Normalize full_state unwrapping in RemoteState once instead of per-accessor #109

@rbren

Description

@rbren

Problem

RemoteState has 8+ getter methods that all follow the same pattern:

async getExecutionStatus(): Promise<ConversationExecutionStatus> {
  const info = await this.getConversationInfo();
  const unwrappedInfo = this.unwrapState(info);  // repeated everywhere
  return unwrappedInfo.execution_status ?? unwrappedInfo.agent_status;
}

async getConfirmationPolicy(): Promise<ConfirmationPolicyBase> {
  const info = await this.getConversationInfo();
  const unwrappedInfo = this.unwrapState(info);  // same thing
  return unwrappedInfo.confirmation_policy;
}

// ... 6 more methods with identical unwrap pattern

The unwrapState call (handling full_state wrapper from API) is repeated in every accessor.

Proposed Fix

Normalize once inside getConversationInfo() so the returned ConversationInfo is always unwrapped:

private async getConversationInfo(): Promise<ConversationInfo> {
  // ... fetch ...
  // Normalize here once:
  if (response.data.full_state) {
    return response.data.full_state as ConversationInfo;
  }
  return response.data as ConversationInfo;
}

Then remove unwrapState() and all per-accessor unwrapping.

Impact

Medium — removes ~16 lines of repetitive code and eliminates a class of bugs where someone forgets to unwrap.


This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions