Add MarkovianStampTool for verifiable provenance receipts#6388
Add MarkovianStampTool for verifiable provenance receipts#6388MarkovianProtocol wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a new ChangesMarkovianStampTool
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/markovian_stamp_tool.py (1)
133-134: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid doing blocking network I/O directly inside
_arun.
_arun()currently executes the synchronous SDK/requestspath inline, so an async caller can block the event loop for up totimeoutseconds per stamp. Offloading_run()to a worker thread keeps concurrent async tool calls responsive.Suggested fix
+import asyncio import json import os from typing import Any @@ async def _arun(self, data: str, label: str | None = None, **kwargs: Any) -> str: - return self._run(data, label=label, **kwargs) + return await asyncio.to_thread(self._run, data, label=label, **kwargs)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/markovian_stamp_tool.py` around lines 133 - 134, The _arun implementation in MarkovianStampTool is currently calling the synchronous _run path inline, which can block the event loop for the duration of the network request. Update _arun to offload _run to a worker thread so async callers stay responsive, and keep the existing data and label arguments flowing through unchanged. Use the MarkovianStampTool._arun and MarkovianStampTool._run methods as the fix points.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/markovian_stamp_tool.py`:
- Around line 119-121: The Markovian stamp result handling assumes receipt is
always a mapping, but `_stamp()` can return a non-dict JSON value and then
`receipt.get()` raises outside the existing error flow. Update
`markovian_stamp_tool.py` in `MarkovianStampTool._stamp`/the receipt-processing
path to validate that `receipt` is a dict-like mapping before accessing
`merkle_root`; if it is not, return the same readable error string with the raw
receipt payload instead of letting an `AttributeError` escape.
In `@lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/README.md`:
- Around line 66-71: The fenced example output in the Markovian provenance
receipt section is missing a language label, which triggers markdown linting.
Update the unlabeled fence in the README example to use a text language tag so
the block is explicitly identified; the relevant content is the receipt snippet
under the markovian-provenance/v1 example.
In `@lib/crewai-tools/tests/tools/markovian_stamp_tool_test.py`:
- Around line 62-63: The test in markovian_stamp_tool_test should also verify
the HTTP response body returned by MarkovianStampTool._run, not just the failure
message and status code. Update the assertions around the result from _run to
include the expected exc.response.text content so the test covers the error
string built from the response body and catches regressions where the body is
dropped.
- Around line 17-23: The test named test_run_uses_sdk_when_available is
currently bypassing the SDK path by mocking MarkovianStampTool._stamp, so it
never verifies MarkovianClient integration. Update the test to inject a fake
markovian module, instantiate MarkovianStampTool, call run(data=...), and assert
the fake client’s stamp() method was invoked and its return value is used. Keep
the focus on the MarkovianStampTool and MarkovianClient symbols so the test
exercises the actual SDK branch.
---
Nitpick comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/markovian_stamp_tool.py`:
- Around line 133-134: The _arun implementation in MarkovianStampTool is
currently calling the synchronous _run path inline, which can block the event
loop for the duration of the network request. Update _arun to offload _run to a
worker thread so async callers stay responsive, and keep the existing data and
label arguments flowing through unchanged. Use the MarkovianStampTool._arun and
MarkovianStampTool._run methods as the fix points.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 212773a3-a9dc-454e-8922-41d1edce2864
📒 Files selected for processing (6)
lib/crewai-tools/src/crewai_tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/README.mdlib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/__init__.pylib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/markovian_stamp_tool.pylib/crewai-tools/tests/tools/markovian_stamp_tool_test.py
|
Thanks for the review. All four items are addressed in 95c90ac:
Verified locally: |
|
Thanks for the review. All four items are addressed on the current branch:
Ready for another look. |
MarkovianStampTool
Adds a tool that lets a CrewAI agent stamp any output and get back a verifiable provenance receipt in one line. Lives under
lib/crewai-tools.Markovian is a content-agnostic provenance primitive. Stamping commits a hash of the data to the chain, anchored to Bitcoin, and returns a Merkle root plus a public verify URL. It proves data existed at a point in time, not that the data is correct. Provenance, not truth.
Why this is useful for agents
Agents produce decisions, analyses, and artifacts that downstream systems and people need to trust. A stamp gives each output a timestamped, tamper-evident record that anyone can check at
https://api.quantsynth.net/verify/<merkle_root>, with no account.Usage
Output:
Notes
MARKOVIAN_API_KEYandwalletare supported for attributed usage.markovianPyPI SDK and falls back to a plain HTTP POST when the SDK is not installed, so it works with the baserequestsdependency.Checklist
lib/crewai-tools/src/crewai_tools/tools/markovian_stamp_tool/Tool, subclassesBaseToolargs_schemawith field descriptionsenv_varsviaField(default_factory=...), lazy SDK importtools/__init__.pyandcrewai_tools/__init__.py(imports and__all__)tests/tools/, deterministic, no live networkREADME.mdwith usageruff check,ruff format, andpytestgreen locallyProject: https://markovianprotocol.com
Source (Apache-2.0): https://github.com/MarkovianProtocol/markovian-protocol
SDK:
pip install markovianSummary by CodeRabbit