Skip to content

feat(runtime): add Thinking pet state with 30s idleAfter for LLM processing gap#1

Open
JJ-zhang-92 wants to merge 1 commit into
ChanceYu:mainfrom
JJ-zhang-92:feature/thinking-state
Open

feat(runtime): add Thinking pet state with 30s idleAfter for LLM processing gap#1
JJ-zhang-92 wants to merge 1 commit into
ChanceYu:mainfrom
JJ-zhang-92:feature/thinking-state

Conversation

@JJ-zhang-92

Copy link
Copy Markdown

Problem

AI agent tools complete in ~1s but the LLM takes 5-20s to process results and generate text. During this gap, CoPet maps the "thinking" event to none (dropped) �� the pet transitions to Idle, leaving users to wonder if the agent crashed.

Changes (6 files, 20 lines)

Rust runtime

  • Add PetStateId::Thinking variant to the enum
  • Map "thinking" event kind to Thinking state
  • Protect Thinking from being immediately overridden by Idle requests
  • Give Thinking a 30s idleAfter (vs the default 1.5s for other temp states) �� LLM processing takes seconds, not milliseconds

Frontend

  • Add "thinking" to PetStateId type union
  • Map thinking AgentState in useAgentState.ts
  • Route thinking to the review sprite row (Row 8) in petAnimation.ts
  • Add thinking case to usePetSounds.ts

Why 30s instead of 1.5s

Upstream uses TEMP_STATE_IDLE_AFTER_MS = 1_500 for all temporary pet states. That works for Running/Review/Jumping �� these are transient tool visualizations. But Thinking represents an LLM processing gap that lasts 5-20s. A 1.5s timeout would cause the pet to snap into Idle while the agent is still working, defeating the purpose of the state.

Backward compatibility

  • New enum variant only (no existing variants changed)
  • Non-Thinking states still use 1.5s idleAfter
  • "thinking" events from existing integrations are a no-op (they map to None today)

Tested

  • Sending {"kind":"thinking"} via local runtime endpoint �� CoPet returns state: thinking with idleAfterMs ~30s
  • tool.before events still get 1.5s idleAfter (unchanged)
  • Thinking to idle transition after 30s confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant