Skip to content

fsapp: roll over oversized Feishu task cards, keep turn numbering - #820

Open
louisss1016 wants to merge 1 commit into
lsdefine:mainfrom
louisss1016:fix/issue-814-feishu-card-rollover
Open

louisss1016 wants to merge 1 commit into
lsdefine:mainfrom
louisss1016:fix/issue-814-feishu-card-rollover

Conversation

@louisss1016

Copy link
Copy Markdown

Addresses #814.

What

Long Feishu tasks froze around step ~50 while the agent kept running: _push() swallowed the platform card-size error (230099 / 11310 / element-exceeds-limit) and step() ignored the result entirely, so nothing ever recovered.

Changes (frontends/fsapp.py only)

  • _push() returns (ok, limit) and the create path now reports limit=True on failure — with msg_id is None, every later push takes the create path, so not rolling over made the card permanently unsendable (issue defect 2).
  • New _rollover() bumps page_no, clears msg_id/final/steps, and posts a continuation note. Clearing steps is the core of defect 1 — without it the "new" card is exactly as large as the overflowing one.
  • turn_base carries numbering across cards: Turn N stays globally contiguous (powered by a monotonic turn_no), and the header shows 📄 工作卡片 2.
  • Proactive rollover at _PAGE_STEPS = 50 — the reporter measured real overflow at ~58 steps with 8000-char details, so the page flips before the API ever rejects the card (issue suggestion chore(gitignore): add mykey.py to ignore sensitive API keys and credentials #2).
  • done() / fail() roll over and retry once before the existing plain-text fallback fires; done() restores self.final after rollover so the final answer survives.
  • _patch_card() keeps returning bool (delegates to the new _patch_card_result()[0]), so update_message() and other callers are unaffected. Limit detection is factored into _is_card_limit_error() (case-insensitive markers).

Important context found while implementing

The issue references _rollover_locked() / _push_sync() / _worker_loop and _DETAIL_LIMIT = 4000 — none of those exist on current main. A rollover implementation was merged in #209 (commit bf002e5b) but was dropped in the subsequent Feishu interface rework (df525560, 2026-05-21); main today has no rollover at all, and the original symptom reproduces structurally. This PR re-lands the rollover behavior adapted to the current _TaskCard structure (no locks: hooks already run serialized on the agent loop, and start/fail use asyncio.to_thread — same exposure as before, unchanged by this PR).

@cuipengcx90 — as discussed, this stays scoped to the rollover defects; your button-pagination approach is complementary and I'm not touching it here.

Tests

frontends/tests/test_fsapp_card_rollover.py — 11 tests via the repo's ast/exec extraction pattern (fsapp.py imports lark_oapi): reactive rollover with contiguous numbering, create-failure-as-limit retry, proactive threshold flip, done()/fail() recovery paths, fallback-once semantics, and the limit-error marker matching.

Full suite: 298 passed; the 3 failures (test_data_backup symlink ×2, test_release_qualification) are pre-existing Windows-env issues, identical before and after this change.

…define#814)

Long Feishu tasks stopped updating around step ~50: _push() swallowed the
platform card-size error (230099/11310) and step() ignored the result, so the
card silently froze while the agent kept running.

- _push() returns (ok, limit); the create path also reports limit=True, since
  a None msg_id otherwise sends every later push down the failing create path
  (defect 2 in the issue)
- new _rollover() clears steps and bumps page_no, so the continuation card is
  actually smaller than the overflowing one (defect 1); turn_base keeps Turn
  numbering contiguous across cards
- proactive rollover at 50 steps (measured overflow ~58) instead of waiting
  for the API to reject the card
- done()/fail() roll over and retry before falling back to plain text

11 new tests via the repo's ast/exec pattern; full suite 298 passed (same 3
pre-existing Windows-env failures as before).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant