--- id: "0699271e-aae8-41f9-a734-927b21270b6c" name: "canvas_next_item()" micro_summary: "Call when you need the next incomplete Canvas assignment — opens it in a new tab and identifies whether it's SIMnet, Connect, or Canvas-native." status: "resolved" see_also: [] scope: "One-call entry point to find and open the next incomplete Canvas assignment. Navigates to dashboard, extracts upcoming assignments, opens the first incomplete one in a new tab, and identifies whether it's SIMnet, Connect, or Canvas-native. The agent's first move every session." --- ## canvas_next_item(days=14) **The agent's first move every session.** One call discovers the next assignment, opens it, and identifies its type. ```bash browser-harness <<'PY' import json result = json.loads(canvas_next_item(days=14)) print(result["type"]) # "simnet" | "connect" | "canvas" print(result["name"]) print(result["course"]) PY ``` ### Flow (internal) 1. Ensures on Canvas dashboard (navigates there if not) 2. `canvas_get_weekly_assignments(days)` — upcoming assignments 3. Picks first with `completed == False` 4. `new_tab(url)` — opens assignment in new tab 5. `canvas_simnet_go()` — tries LTI navigation 6. If SIMnet/Connect succeeds → returns `simnet_result` 7. If no tool_launch iframe → returns `page_text` (body text, 5000 char cap) ### Return (parse with json.loads) **Success — SIMnet/Connect:** ```json {"ok": true, "name": "...", "course": "...", "url": "...", "type": "simnet", "simnet_result": {"ok": true, "url": "...", "type": "simnet"}} ``` **Success — Canvas-native:** ```json {"ok": true, "name": "...", "course": "...", "url": "...", "type": "canvas", "page_text": "..."} ``` **Error:** ```json {"ok": false, "error": "no assignments due within 14 days"} {"ok": false, "error": "all assignments complete"} {"ok": false, "error": "no planner found. navigate to canvas dashboard first"} ``` ### What happens to browser tabs - Opens assignment in a **new tab** (doesn't clobber existing tabs) - If SIMnet/Connect: the new tab navigates through the LTI redirect chain to the assignment - If Canvas-native: the new tab stays on the Canvas assignment page - Dashboard tab is preserved ### Next steps by type | type | Next call | |------|-----------| | `simnet` | `simbook_complete()` or manual SIMnet interaction | | `connect` | Read Begin Button skill, then click the Begin button | | `canvas` | Read `page_text`, respond to user with assignment details |