parse_post_prompt_data

View as MarkdownOpen in Claude

Return post_prompt_data as a plain dict, whichever shape it arrived in:

  • A {"parsed": {...}} or {"parsed": [ {...} ]} wrapper is unwrapped first.
  • A flat object with real keys is returned as-is, minus raw and parsed.
  • A {"raw": "..."} string is unfenced with strip_json_fence() and parsed as JSON. Prose that isn’t JSON becomes {"summary": "<the prose>"}.

Never raises. A malformed summary degrades to {} rather than failing the request that delivered it.

Parameters

data
AnyRequired

The post_prompt_data value from a post-prompt body.

Returns

dict[str, Any] — The summary object, or {} when there is nothing usable.

Example

from signalwire.core.post_prompt import parse_post_prompt_data
summary = parse_post_prompt_data(raw_body.get("post_prompt_data"))
print(summary.get("intent"))

Part of the post-prompt normalization module.