Python: Add a read-only TaskMarket delegation sample - #7616
Conversation
|
dacode-dev please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds a read-only Python TaskMarket delegation sample for discovering and inspecting public tasks through agent tools.
Changes:
- Adds a standard-library TaskMarket API client.
- Exposes discovery and inspection as Agent Framework tools.
- Adds documentation and offline unit tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
taskmarket_client.py |
Implements API access and task normalization. |
taskmarket_delegation.py |
Defines tools and configures the agent. |
test_taskmarket_client.py |
Tests filtering, normalization, and ID validation. |
TASKMARKET_README.md |
Documents safeguards, setup, and checks. |
README.md |
Lists the new sample. |
Suppressed comments (1)
python/samples/02-agents/tools/test_taskmarket_client.py:52
- This second
objectannotation also makes bothreturn_valueandassert_called_onceinvalid attribute accesses under the samples type checks. Use the patched mock type here as well.
def test_exact_task_is_read_only(self, urlopen: object) -> None:
task_id = "0x" + "c" * 64
urlopen.return_value = FakeResponse({"id": task_id, "reward": "1000000", "status": "open"})
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| try: | ||
| amount = Decimal(str(value)) / Decimal(1_000_000) | ||
| except (InvalidOperation, ValueError): | ||
| return None | ||
| return format(amount, "f") |
| raw_tasks = payload if isinstance(payload, list) else payload.get("tasks", []) | ||
| if not isinstance(raw_tasks, list): | ||
| raise TaskMarketError("TaskMarket returned an unexpected task list") |
|
|
||
| class TaskMarketClientTests(unittest.TestCase): | ||
| @patch("urllib.request.urlopen") | ||
| def test_discovery_filters_and_normalizes_rewards(self, urlopen: object) -> None: |
| return Agent( | ||
| client=OpenAIChatClient(), | ||
| name="TaskMarketResearchAgent", |
Related issue: #7615
Adds a focused Python sample showing how Agent Framework can expose TaskMarket discovery as agent tools.
Checks:
python3 -m unittest discover -s samples/02-agents/tools -p "test_taskmarket_client.py";python3 -m py_compile samples/02-agents/tools/taskmarket_client.py samples/02-agents/tools/taskmarket_delegation.py.