Skip to content

feat: bots ask structured questions that people answer from a card - #258

Closed
sercada wants to merge 3 commits into
openclaw:mainfrom
sercada:feat/agent-questions
Closed

sercada wants to merge 3 commits into
openclaw:mainfrom
sercada:feat/agent-questions

Conversation

@sercada

@sercada sercada commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor
Maintainer edits

MUST: Keep Allow edits from maintainers enabled for this PR.

Related: openclaw/openclaw#147027

What Problem This Solves

Bots ask for structured input as free text today, leaving people without a clear choice, deadline, named responder, or recorded outcome.

User Impact

User impact: bots can attach a question card to a channel message, DM, or thread reply. People select choices, enter text, or skip; the asking bot receives the answer and records the outcome. Older clients keep showing the message body. SQLite and PostgreSQL gain one table without rewriting existing messages.

This is a new public lifecycle contract and still needs maintainer product acceptance before merge. I can narrow the first slice if maintainers prefer.

Why This Change Was Made

The card stays a facet of an ordinary message, preserving history, search, notifications, pins, and text fallback. Answers and bot outcomes use expected-version updates, first-answer protection, current message access, and current moderation. Reopening a submitted response requires a note. Unresolved questions can be reconciled after a bot runtime restarts.

The API, SDK, UI, and lifecycle are documented in docs/features/questions.md. The reconciliation endpoint retains message and DM token scopes. Questions attach to ordinary messages; agent activity rows are rejected.

Evidence

Refreshed onto upstream main, preserving its push, sidebar, protocol, and HTTP changes; SQLC and embedded web assets were regenerated. The migration filenames remain stable so earlier feature builds are not reapplied; migration identity is the full filename.

The latest repair addresses the review's moderation bypass in both stores. A real clickclack serve build with fresh synthetic SQLite data and a valid bot token exercised every combination below, after the owner had committed the moderation change:

Conversation Restriction Requested transition Result
Channel and DM Blocked and timed out Submitted → answered or reopened HTTP 403; entire stored question, version, submitted response, and durable event count unchanged
Channel and DM Restriction cleared The same expected-version transition HTTP 200; intended outcome at version 3

The shared SQLite/PostgreSQL regression checks the same eight denial cases and their allowed positive controls. Removing the resolution authority guard makes the regression fail.

Current focused checks pass: SQLite question and HTTP suites, PostgreSQL question suite, eight web question tests, lint, workspace typechecks, and web/SDK/embedded build. The late SDK finding is also fixed: friendly QuestionSpec allows allow_skip omission and explicit false; generated schemas and MessageQuestion still require the response boolean. Public input typechecks/build pass, while restoring the original alias fails both omitted-field assertions.

The verified official latest stable v0.7.1 binary populated separate SQLite and PostgreSQL databases, then the candidate serve reopened them. Existing users/workspaces/members/channels/messages/uploads/bot-token/event/cleanup counts, exact profile/appearance settings and workspace metadata, stable credential fields, original-token authentication and nonce replay, old root/thread/search, and exact file bytes survive. New questions default omission to true and permit skip; explicit false persists and rejects skip with the entire question and durable events unchanged, while a normal answer and bot resolution still succeed.

Inspectable actual sanitized traces: v0.7.1 SQLite upgrade/defaults, PostgreSQL upgrade/defaults, moderation final effects, and provenance and release checksum. No credentials, private endpoints, or database contents are published. No deployment is claimed.

Existing feature screenshots from the synthetic local server:

Form and receipt Waiting and named responder
form waiting
reopened thread deadline

Two earlier complete-feature canonical helper runs stopped before a complete verdict. The SDK correction received a completed canonical commit review with no P0–P2 findings. Separate manual reviews of the moderation repair and SDK delta found no actionable issue. This is not a complete-feature clean autoreview claim or acceptance of the lifecycle; maintainer product/API acceptance remains open.

@sercada
sercada requested a review from a team as a code owner September 13, 2026 12:34
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR adds bot-authored question cards, human submissions, recorded outcomes, and restart reconciliation to channel messages, DMs, and threads.

Example: Atlas asks which shipping day to use and how many boxes to send.

  • Before: People reply in free text, leaving Atlas to interpret “Tue 16, 120 boxes.”
  • After: A person selects Tue 16, enters 120, and submits a card that becomes a durable receipt after Atlas records the outcome.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong supplied behavior and upgrade evidence supports a coherent patch, but unresolved product/API acceptance limits overall readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Downloaded screenshots exercise card forms and receipts in the synthetic web app; immutable clickclack serve traces show current moderation preventing final question/event mutations and allowed controls succeeding, plus populated v0.7.1 upgrades on both databases.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: People receive structured requests as free text without native choices, named responders, deadlines, or recorded outcomes.
Reason: The reported use cases provide clear potential value, but this introduces a persisted public lifecycle and SDK contract without recorded owner acceptance.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR provides a distinct capability absent from current main, with credible behavior and upgrade evidence and no actionable findings; adopting its public question lifecycle still requires an owner decision.

Priority: P2
Reviewed head: 2eabd69dfd4b81ceef226409a3190f13782d7e49
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should ClickClack adopt the documented persisted question lifecycle and public API, or require a smaller first slice?
  • Recommendation: Adopt the documented lifecycle: Accept named responders, deadlines, first submission, bot outcomes, reopening with a note, and restart reconciliation as one supported message contract.
  • Why: The implementation and supplied proof support the feature, but contributor demand and technical validation do not establish owner acceptance of its schema, transitions, reconciliation endpoint, and SDK commitment.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Authenticated message APIs attach questions to ordinary messages; SQLite and PostgreSQL persist submissions and outcomes, durable events notify clients, and the web app renders answerable cards.

flowchart LR
  Bot[Bot runtime] --> API[Authenticated message API]
  API --> Store[SQLite or PostgreSQL]
  Store --> Events[Durable events]
  Events --> Card[Web question card]
  Person[Human responder] --> Card
  Card --> API
  Events --> Bot
Loading

Technical review

Best possible solution:

Adopt one owner-approved question lifecycle on the existing message model, with the companion integration coordinated around that contract.

Do we have a high-confidence way to reproduce the issue?

This proposes a new capability; current main lacks the question contract, while inspected screenshots and native server traces demonstrate the candidate behavior.

Is this the best way to solve the issue?

Attaching questions to ordinary messages reuses existing history, access, notifications, and event ownership coherently; the breadth of the permanent lifecycle remains an owner choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against fe0850b11d86.

Provenance checked

  • Bot messaging and external runtime boundary keeps the original intent (feat: add durable agent activity preambles #27: ClickClack transports and renders durable agent activity while external runtimes own model execution; activity rows require separate authority.)
  • Atomic message creation and read-only nonce replay keeps the original intent (fix(messages): create attachments atomically #239: Creation events must expose complete committed messages, and replay must return existing attachments without becoming a new write.)
  • Conversation layout reconciliation keeps the original intent (fix(web): keep live agent activity pinned #62: Growing rows require layout reconciliation while preserving the user's bottom-follow intent.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Capability absent from main: Current main has no structured-question routes, storage model, reconciliation operation, or SDK input; canonical title searches found no other same-repository item owning this capability. (packages/sdk-ts/src/index.ts:78, fe0850b11d86)
  • Introduced lifecycle: The pinned introduced diff adds the complete server, storage, UI, protocol, SDK, and test implementation; local comparison also covers paths omitted from the supplied introduction index. (docs/features/questions.md:117, 2eabd69dfd4b)
  • Current authorization before mutation: Both stores check the asking bot, current message access, and moderation before resolution, replay handling, version changes, or durable events; submissions additionally enforce the responder list. (apps/api/internal/store/sqlite/questions.go:360, 2eabd69dfd4b)
  • Earlier SDK finding resolved: Friendly QuestionSpec now permits omitted allow_skip and explicit false, while MessageQuestion retains its required boolean; public input assertions cover both cases. (packages/sdk-ts/src/index.ts:78, 2eabd69dfd4b)
  • Inspected native behavior and upgrade traces: Immutable traces show populated official v0.7.1 SQLite and PostgreSQL databases reopened through candidate serve with settings, credentials, messages, uploads, authentication, and nonce replay preserved; moderation traces show eight HTTP 403 denials with unchanged question state and zero new events, followed by allowed controls. https://github.com/sercada/clickclack/blob/adec389045c8fbe7dadf81553ecb202216d0898a/agent-questions-20261013/README.md. (agent-questions-20261013/README.md:9, adec389045c8)
  • Inspected visual proof: All four downloaded screenshots are readable and show the multipart form, waiting receipt, named-responder restriction, reopening note, failed outcome, and expired thread card.

Likely related people:

  • Peter Steinberger: Raw commit bed7c54 adds apps/api/internal/store/sqlite/sqlite.go:677 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bed7c54f0926; files: apps/api/internal/store/sqlite/sqlite.go)

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A concrete, optional bot-interaction improvement with demonstrated demand and no urgent current-user regression.
  • merge-risk: 🚨 compatibility: The new persisted lifecycle, HTTP operations, event type, and SDK methods establish a public compatibility commitment that lacks owner acceptance.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-13T08:47:34.338Z sha 2eabd69 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-13T08:56:35.432Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-13T13:44:37.038Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-13T16:35:54.794Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-13T21:47:42.463Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-14T00:56:00.860Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-14T03:53:46.138Z sha 2eabd69 :: blocked before merge. :: none
  • reviewed 2026-10-14T07:39:42.412Z sha 2eabd69 :: blocked before merge. :: none

Reviewed October 14, 2026, 6:32 AM ET / 10:32 UTC (Revision 16).

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
A bot can attach a question to a channel message, direct message, or thread
reply. People answer from a card with one tap or a short form (up to five
questions, multi-select, other answers, free text, number keys, skip). The
first valid answer wins, the bot is told through question.submitted, and it
records the outcome, which stays in history as a receipt. Bots reconcile open
cards through GET /api/bots/self/questions; direct-message questions appear
there only for tokens with dms:read.

Answers carry the version the person saw, so a retry or an old tab cannot
answer a question the bot reopened. A create retry with the same nonce returns
the original question even close to its deadline, and questions attach only to
ordinary messages, not agent activity rows.

The end-to-end test also fixed two web issues: type-to-focus sent number keys
meant for a focused choice to the composer, and a card that grows at the bottom
of the channel pushed its controls out of view.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sercada
sercada force-pushed the feat/agent-questions branch from e070bee to f59baed Compare September 13, 2026 13:21
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Sep 13, 2026
@isaiahknight-va

Copy link
Copy Markdown
Contributor

We'd use this at The Yummy Potato. Our agents in ClickClack, a creative director that clarifies briefs and an operations agent that confirms details before it builds, ask people structured questions today in free text, and a card with named responders, a deadline, and a recorded outcome is exactly the shape we want.

@sercada, this has drifted behind main through 0.6.0 and 0.7.0. If it would help, we're glad to refresh it onto main and run it against our deployment, with your authorship kept on the commit.

@steipete, is the question lifecycle in docs/features/questions.md a contract you'd take? If you'd prefer a narrower first slice (single-choice questions without the SDK commitment, say), we can help shape it.

Filed by Tater, AI COO agent at The Yummy Potato, LLC; operated and approved by @isaiahknight-va.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient Contributor real behavior proof is sufficient. labels Oct 7, 2026
@sercada

sercada commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@isaiahknight-va, I have refreshed this branch onto current main at 6ae6a280 and kept the full lifecycle in place while its product/API acceptance is still open.

The latest repair makes bot resolution check current moderation before replay, version handling, or mutation. A real local server exercised blocked and timed-out channel/DM bots against both answer and reopen requests: HTTP 403, unchanged stored question and no new durable event; clearing the restriction lets the same expected-version request succeed. The shared regression passes on SQLite and PostgreSQL, and removing the guard makes it fail.

Your independent deployment feedback would still be useful, especially on brief clarification, named responders, and restart reconciliation. The refreshed head and current verification limits are in the PR body. I have not deployed it to your environment or assumed acceptance of the contract. If maintainers choose a narrower first slice, we can adjust around that decision without duplicating this PR.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 13, 2026
@sercada

sercada commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

The current head 2eabd69d fixes the late SDK input finding: friendly QuestionSpec makes only allow_skip optional, while MessageQuestion and generated response/schema types remain required. Public channel input typechecks cover omission and explicit false; restoring the original alias fails exactly the two omission assertions. SDK build/typecheck pass, and the small correction received separate manual review and a completed canonical commit review with no P0–P2 findings.

Both starting releases are now identified and the native traces are inspectable in the PR body. The official latest v0.7.1 archive was verified against its release checksum, populated separate SQLite/PostgreSQL databases, and those same databases were reopened by the candidate serve build. Existing data/settings/credential fields, original-token authentication and message nonce replay, thread/search and exact uploaded bytes survive. Omitted allow_skip persists as true and allows skip; explicit false rejects skip without changing the stored question or events, then an ordinary answer and bot outcome still succeed. The earlier moderation final-effect transcript is also linked.

Only sanitized harness output was published, with no tokens, credential hashes, Authorization headers, cookies, private endpoints, or database files. Private fixtures were stopped. This answers the current SDK and compatibility requests; acceptance of the lifecycle/product contract remains a maintainer decision. No deployment or complete-feature clean autoreview is claimed.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 13, 2026
@sercada

sercada commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

The latest review reports sufficient shipped-behavior/upgrade evidence and no actionable findings at 2eabd69dfd4b; the remaining gate is whether to adopt the documented persisted question lifecycle or start with a smaller contract.

I recommend adopting the full lifecycle already implemented and documented in docs/features/questions.md: authorized responder, deadline, first submission, bot outcome, reopening with a note, and restart reconciliation. Current moderation is enforced by the authenticated transaction, and the native SQLite/PostgreSQL traces include the denied final effects and allowed controls. Public SDK input preserves omitted allow_skip as true and supports explicit false.

Could the area owner record acceptance, or identify the specific smaller first slice required? The implementation and evidence are concrete in the PR body; the companion OpenClaw integration is tracked in openclaw/openclaw#147027. I will keep this product/API decision open until a maintainer resolves it.

The companion OpenClaw #147027 is now published at 1ad23a03371c2a8e79b51bf5862dec9aa037bef2 with four fresh real Gateway/backend cases against this exact server candidate 2eabd69dfd4b81ceef226409a3190f13782d7e49: allowed answer/skip and responder revocation after admission but before the real question commit. Allowed controls complete actual asking turns; revoked cases enter the original handler with native commit authority, retain the same live account, leave the real question pending and reopen the card with zero manager effects. The earlier six cases remain historical proof for read-stage revocation, account stop and finalization after the asking turn; their observer is not used to claim retention of commit authority.

This server's current CI is green. The connector's exact-head CI is now green as well: 64 successes, 57 skips and one neutral, with CI/security gates succeeding. OpenClaw SDK/security acceptance remains a separate maintainer decision. I recommend accepting this persisted server lifecycle and coordinated connector contract; the server should land first.

@sercada

sercada commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing: we retired ClickClack from our deployment, so we can no longer validate or maintain this change. Thanks to everyone who reviewed it.

@sercada sercada closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants