Hmbown/CodeWhale · error

message should serialize

Error message

message should serialize

What it means

A test-only expect("message should serialize") panic in the interrupted-assistant round-trip test: serde_json failed to serialize a Message with role Role::InterruptedAssistant and partial text content. It means that role or its content blocks are not JSON-serializable, which would break session persistence of interrupted turns.

Solutions

  1. Check the Serialize impl on Role::InterruptedAssistant and the ContentBlock variants used
  2. Ensure the role serializes to a stable string tag that Deserialize can map back
  3. Re-run the round-trip test after fixing so serialize then deserialize reproduce the same Message
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/models/src/lib.rs:924 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/c30eff6739ce04e6. Report an issue: GitHub.

Appendix: source

Thrown at crates/models/src/lib.rs:924

            top_p: None,
        };
        let via_core_path: codewhale_core::request::MessageRequest = via_tui_path.clone();
        assert_eq!(
            serde_json::to_vec(&via_tui_path).expect("serialize TUI path"),
            serde_json::to_vec(&via_core_path).expect("serialize core path")
        );
    }

    #[test]
    fn interrupted_assistant_role_round_trips_as_distinct_session_item() {
        let message = Message {
            role: Role::InterruptedAssistant,
            content: vec![ContentBlock::Text {
                text: "partial output".to_string(),
                cache_control: None,
            }],
        };
        let encoded = serde_json::to_string(&message).expect("message should serialize");
        let decoded: Message = serde_json::from_str(&encoded).expect("message should deserialize");
        assert_eq!(decoded, message);
        assert_ne!(decoded.role, "assistant");
    }

    #[test]
    fn unrecognized_deepseek_models_do_not_inherit_sibling_metadata() {
        for model in [
            "deepseek-v4-flash-20260423",
            "deepseek-v4-pro-20260423",
            "deepseek-coder",
            "deepseek-v3.2-0324",
            "deepseek-v4.1-flash-expires-on-0910",
        ] {
            assert_eq!(context_window_for_model(model), None, "{model}");
        }
        assert!(!model_supports_reasoning(
            "deepseek-v4.1-flash-expires-on-0910"

View on GitHub (pinned to 433685b202)