Code RoomRecovering from invalid API assumptions
MediumPrep Room Coding #4044

Recovering from invalid API assumptions

Vibe & agenticAlgorithms & data structuresMid–Senior~16 min

You ask an AI agent to add a Rust function that parses a `Duration` from strings like `"1h30m"`, `"45s"`, `"2d"`. Its first attempt uses `chrono::Duration::from_str`, which doesn't exist; you tell it 'that API isn't real' and it pivots to `humantime::parse_duration` — but your crate can't add new dependencies, and `humantime` rejects `"2d"` plus the compound `"1h30m"` form anyway. You're three messages deep and still broken. How do you diagnose what's going wrong and re-steer it to get a working parser?

Implement
parse_duration_seconds(text: str) → int
Examples
in["1h30m"]out5400
in["45s"]out45
in["2d"]out172800
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 16 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.