Skip to content

feat: Add CogDx reasoning verification connector#215

Open
drkavner wants to merge 8 commits intoPolymarket:mainfrom
drkavner:feature/cogdx-reasoning-verification
Open

feat: Add CogDx reasoning verification connector#215
drkavner wants to merge 8 commits intoPolymarket:mainfrom
drkavner:feature/cogdx-reasoning-verification

Conversation

@drkavner
Copy link

@drkavner drkavner commented Mar 13, 2026

Summary

Adds an optional cognitive diagnostics integration for verifying agent reasoning before trade execution.

What it does

  • CogDxClient: Client for Cerebratech's Cognitive Diagnostics API
  • Pre-trade verification: Analyze reasoning traces for logical fallacies before executing
  • Calibration audits: Track if agent confidence matches actual accuracy over time
  • Bias detection: Scan for anchoring, confirmation bias, availability heuristic, etc.

Why this matters for prediction market agents

Prediction markets reward accurate reasoning. Common agent failure modes:

  1. Anchoring on market price as signal rather than independent estimate
  2. Confirmation bias in research (finding evidence for existing position)
  3. Overconfidence in stated probabilities
  4. Logical fallacies in reasoning chains

External verification catches these before they become losses.

Usage

from agents.connectors.cogdx import verify_trade_reasoning

# Quick gate before trade execution
if verify_trade_reasoning(reasoning, coupon="MERCURY-PILOT-2026"):
    polymarket.execute_market_order(market, amount)
else:
    print("Reasoning flagged for review")

See docs/cogdx_integration.md for full documentation.

Free pilot

Coupon code MERCURY-PILOT-2026 provides $5 credit (~80 reasoning verifications).

About

Built by Cerebratech - cognitive diagnostics for AI agents, designed by computational cognitive scientists.


Happy to adjust the integration approach based on your feedback. This is purely additive and optional - doesn't change any existing behavior.


Note

Low Risk
Additive connector and documentation only; no existing trade/execution paths are modified unless callers opt in. Main risk is reliance on a third-party API (timeouts/errors) when used, but the helper defaults to failing closed.

Overview
Adds a new CogDxClient connector that calls Cerebratech’s API to analyze reasoning traces, run calibration audits, scan for cognitive biases, and optionally gate trade execution via verify_before_trade (with explicit handling for payment-required and other HTTP errors/timeouts).

Includes a convenience verify_trade_reasoning helper and new docs/cogdx_integration.md describing setup (env vars/coupon/wallet), usage examples, and the intended fail-closed behavior when the service is unavailable.

Written by Cursor Bugbot for commit 4916c25. This will update automatically on new commits. Configure here.

Adds optional cognitive diagnostics integration for trade verification:

- CogDxClient for reasoning analysis before trade execution
- Detects logical fallacies, calibration issues, cognitive biases
- Pre-trade verification gate with configurable thresholds
- Free pilot coupon: MERCURY-PILOT-2026

This helps prediction market agents catch reasoning flaws before
they become losses. External verification from computational
cognitive science methodology.

See docs/cogdx_integration.md for usage examples.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Polymarket Agents. Thank you for creating your first PR. Cheers!

@drkavner
Copy link
Author

Additional context on Cerebratech's approach

Human-AI Collaborative Research

This integration is built through active collaboration between Dr. Amanda Kavner (computational cognitive scientist, PhD) and AI agent researchers. Not prompt engineering—actual cognitive science methodology applied to agent reasoning.

Built-in Feedback Loop

Every diagnosis includes a feedback mechanism. When agents report whether a detection was accurate, that feedback directly improves the model. Each use makes the next one better:

client.submit_feedback(
    diagnosis_id="rta_xyz123",
    accurate=False,
    comments="Missed the anchoring bias in step 3"
)

Rebate for Feedback

Agents who provide feedback earn credits:

  • Confirm accuracy: $0.02
  • Flag inaccuracy: $0.05
  • Detailed comments: +$0.03

The system pays you to make it smarter. This creates a flywheel: more usage → more feedback → better accuracy → more value → more usage.

Happy to discuss further!

@drkavner
Copy link
Author

Why trust this integration?

Fair question for any third-party dependency. Here's the background:

About the research team

Dr. Amanda Kavner - Computational cognitive scientist (PhD) researching how humans and AI systems understand the world. Academic background in:

  • Cognitive process modeling
  • Bias identification and measurement
  • Training/retraining methodologies

This isn't a weekend project or GPT wrapper. The detection methods are based on established cognitive science research (Kahneman & Tversky's heuristics work, calibration literature, etc.).

Why we built this

Most AI "bias detection" tools are prompt engineering. They ask an LLM "does this seem biased?" That's circular—you're using a potentially biased system to detect bias.

Our approach:

  1. Pattern-based detection for known fallacy structures
  2. Calibration metrics comparing stated confidence to accuracy
  3. Continuous improvement via user feedback loop

The trust model

  • Optional integration — doesn't touch your core trading logic
  • Graceful degradation — if our API is down, trades proceed normally
  • No data retention — reasoning traces are not stored beyond the request
  • Open to audit — happy to share methodology details

Try before you trust

The free pilot (MERCURY-PILOT-2026) lets you test with real data before committing. Run your existing reasoning traces through it, see what it catches.

If it doesn't add value, don't merge. No pressure—we'd rather have users who find it genuinely useful.


Happy to jump on a call or provide more details. You can reach Dr. Kavner directly if that helps build confidence.

@drkavner
Copy link
Author

About me

For context on my background: I'm a professor of scientific thinking and truth verification, and an international speaker on scientific literacy.

LinkedIn: https://www.linkedin.com/in/drkavner/

Happy to jump on a call to discuss the methodology behind this, or answer any questions here.

—Dr. Kavner

1. Fail closed on API errors (don't auto-approve unverified trades)
2. Handle null validity values to prevent TypeError
3. Remove promotional content from docs and code
4. Document safety design (opt-in, graceful degradation)
@drkavner
Copy link
Author

Addressed Bugbot Review Feedback

Thanks for the thorough review! Fixed all 3 issues:

1. Fail-Closed on API Errors ✅

Changed verify_before_trade to return approved: False when the API is unavailable. Safety gates should not auto-approve when they can't verify.

2. Null Validity Handling ✅

Fixed the dict.get() behavior for null values. Now explicitly checks for None and defaults to 0.

3. Removed Promotional Content ✅

  • Removed coupon codes from docs and code comments
  • Removed pricing tables
  • Made docs more neutral/technical
  • Added "Safety Design" section documenting fail-closed behavior

The integration is designed to be:

  • Optional: Entirely opt-in, doesn't affect core trading
  • Safe: Fails closed on errors (no unverified approvals)
  • Transparent: No data retention, reasoning traces not stored

Let me know if you need any other changes!

1. Document 'skip' recommendation in docstring
2. Restore coupon parameter to convenience function
@drkavner
Copy link
Author

Fixed additional feedback:

  1. ✅ Docstring now documents 'skip' recommendation for error cases
  2. ✅ Convenience function now accepts both coupon and wallet parameters

Commit: e036637

1. Flaws can be strings or dicts - check type before .get()
2. Check response.ok for all HTTP errors, not just 402
@drkavner
Copy link
Author

Hi team,

I'm Dr. Amanda Kavner, the researcher behind the CogDx integration in PR #215. I wanted to reach out directly since the automated reviews flagged some valid concerns I'd like to address.

Why this integration

Prediction market agents make high-stakes decisions based on probabilistic reasoning. The challenge: agents can't reliably audit their own reasoning for biases and logical flaws. It's the same problem humans have — you can't step outside your own cognition to verify it.

I'm a computational cognitive scientist (professor of scientific thinking, international speaker on scientific literacy). My research focuses on how humans and AI systems understand the world, identify biases, and improve calibration. This integration applies that methodology to trading agents.

The feedback loop — shared reality

Every diagnosis includes a feedback mechanism. When agents report whether a detection was accurate or missed something, that feedback directly improves the model for everyone. This creates a shared reality across agents:

  • Agent A catches a bias we missed → reports it → detection improves
  • Agent B benefits from that improvement on their next call
  • Over time, the system learns which cognitive patterns actually predict bad trades

Individual agents can't build this alone. The value compounds across the network — each agent contributing to collective reasoning verification.

The value proposition

External verification catches what self-checks miss. When an agent is anchoring on recent prices or exhibiting confirmation bias, it can't detect that from the inside. A third-party audit can — and the feedback loop makes it smarter over time.

Complementary tooling

We've also published a standalone skill on ClawHub that works with Simmer SDK:

clawhub install cogdx-pre-trade-audit

This provides an alternative integration path for agents who want to test cognitive verification without modifying the core Polymarket agents codebase.

Happy to jump on a call to discuss the methodology, answer questions, or make further changes.

Best,
Dr. Amanda Kavner
https://www.linkedin.com/in/drkavner/

- Binary core: accurate (bool) - was detection correct?
- Numerical enrichment: confidence (0-1), severity (1-5), accuracy_score (0-1)
- Structured context: outcome, reasoning, wallet for credits
- Signal strength calculation for learning algorithms
- Network effects: feedback builds shared reality across agents
…andling

Bugbot fixes:
1. submit_feedback was dead code after return statement - now properly inside class
2. calibration_audit and bias_scan now check response.ok before parsing JSON
3. All methods now return consistent error structures

This ensures:
- Feedback submission is callable via client.submit_feedback()
- Non-200 responses don't cause silent failures
- Error handling is consistent across all methods
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

1. submit_feedback now checks response.ok before parsing JSON
2. verify_before_trade uses approved variable instead of duplicating logic
3. Consistent error handling across all methods
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