{"record":{"id":"6e9539ecb56b0fab","repo":"Hmbown/CodeWhale","slug":"pythonruntime-with-state-path-is-deprecated-use","errorCode":null,"errorMessage":"PythonRuntime::with_state_path is deprecated — use PythonRuntime::new() or PythonRuntime::spawn_with_context()","messagePattern":"PythonRuntime::with_state_path is deprecated — use PythonRuntime::new\\(\\) or PythonRuntime::spawn_with_context\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/repl/runtime.rs","lineNumber":187,"sourceCode":"\nimpl PythonRuntime {\n    /// Spawn a REPL with no `context` variable and no LLM helpers wired up.\n    /// Used by the agent loop for inline `repl` blocks the model emits in\n    /// regular conversation.\n    pub async fn new() -> Result<Self, String> {\n        Self::spawn_inner(None, Some(ROUND_TIMEOUT)).await\n    }\n\n    /// Compatibility shim — older RLM code path used to pass a state file.\n    /// The state file is no longer used, but the path doubles as an extra\n    /// scratch location callers can rely on for cleanup symmetry.\n    pub fn with_state_path(_path: PathBuf) -> Self {\n        // Synchronous constructor is no longer meaningful: spawning Python\n        // is async. Callers in turn.rs already use `spawn_with_context` —\n        // this stub is kept only so the public surface compiles for any\n        // out-of-tree user. It returns a deliberately broken runtime that\n        // panics on first use, which is preferable to silently lying.\n        unreachable!(\n            \"PythonRuntime::with_state_path is deprecated — \\\n             use PythonRuntime::new() or PythonRuntime::spawn_with_context()\"\n        )\n    }\n\n    /// Spawn a REPL with the long input preloaded from a file. Used by the\n    /// RLM turn loop.\n    pub async fn spawn_with_context(context_path: &Path) -> Result<Self, String> {\n        Self::spawn_inner(Some(context_path), None).await\n    }\n\n    async fn spawn_inner(\n        context_path: Option<&Path>,\n        round_timeout: Option<Duration>,\n    ) -> Result<Self, String> {\n        let session_id = Uuid::new_v4().simple().to_string();\n        let bootstrap = render_bootstrap(&session_id);\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/repl/runtime.rs#L169-L205","documentation":"While streaming an Anthropic-model response, one SSE event failed to parse from the provider's event stream. The malformed event is logged and skipped - the stream keeps yielding subsequent events and only ends at MessageStop - so a single bad event degrades content (a missing delta) rather than failing the whole turn.","triggerScenarios":"A malformed SSE frame from an Anthropic-compatible endpoint: a proxy or gateway rewriting/chunking the stream incorrectly, an intermediate layer corrupting event lines, or a provider protocol change introducing an event shape the client's deserializer rejects.","commonSituations":"Third-party Anthropic-compatible gateways with subtly different SSE framing; corporate proxies buffering or mangling event streams; version skew between codewhale's protocol support and a newly deployed provider API.","solutions":["Point base_url directly at the real Anthropic endpoint to rule out gateway/proxy mangling","Upgrade codewhale - new event variants are protocol additions picked up in newer releases","Capture the raw stream (curl -N) and compare event names/payload shapes against what the client expects","If answers look truncated, check whether the skipped event was a content_block_delta or whether MessageStop ever arrived"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Smoke-test the endpoint's SSE framing before pointing codewhale at it:\n// curl -N https://gateway/v1/messages -H 'content-type: application/json' -d @req.json\n// verify event:/data: lines match Anthropic's framing","typeGuard":"// Narrow only the events you depend on; tolerate skips of other kinds.\nif let Ok(event) = result {\n    if let StreamEvent::ContentBlockDelta(delta) = event {\n        accumulate(delta);\n    }\n}","tryCatchPattern":"// Detect silent truncation: if MessageStop never arrived within the deadline,\n// the skipped event may have cost real content - retry the turn instead of\n// accepting a partial answer.\nif !saw_message_stop {\n    retry_turn();\n}","preventionTips":["Prefer first-party endpoints over SSE-rewriting proxies","Upgrade codewhale alongside provider API changes","Inspect answers for missing text after any gateway or proxy change"],"tags":["sse","streaming","anthropic","protocol"],"backgroundTag":"sse-parse-error","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}