Skip to content

Commit bedec91

Browse files
committed
fix(tests): pass target_person/target_repository to LLM contribution agent
Two tests in `test_llm_contribution_agent.py` regressed when CI started running them (they were previously masked by an import-time crash): - `test_llm_contribution_agent_validates_payload_and_exposes_model_metadata` - `test_llm_contribution_agent_records_strict_schema_warnings` Both hit the fail-closed branch added in commit 6700f6f (orphan- Contribution drop): if `target_person`/`target_repository` are missing from the agent context the agent emits `{}` instead of a half-built Contribution. In production the orchestrator always sets these fields before invoking the agent; the tests bypass the orchestrator and call `agent.run()` directly with minimal context. Add `_person_and_repo_context()` helper that supplies the minimum context the orchestrator passes today, and inject it into both failing tests. The other three tests in the file already exercise pre-LLM-call paths (timeout / runtime error / capture), so they don't need it.
1 parent cc3df92 commit bedec91

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

tests/v2/test_llm_contribution_agent.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ def _valid_contribution_payload() -> dict[str, Any]:
6161
}
6262

6363

64+
def _person_and_repo_context() -> dict[str, Any]:
65+
"""Minimum context the orchestrator passes to the contribution agent.
66+
67+
`target_person` / `target_repository` are required by
68+
`LLMContributionAgentV2.run()` (see the orphan-Contribution guard in
69+
`src/v2/agents/llm/contribution/agent.py`): when missing, the agent
70+
fail-closes and emits `{}` so no Contribution can leak into the graph
71+
without both `schema:author` and `pulse:contributionTo`.
72+
"""
73+
return {
74+
"known_persons": [{"id": "alice", "type": "schema:Person"}],
75+
"known_repositories": [
76+
{"id": "owner/repo", "type": "schema:SoftwareSourceCode"},
77+
],
78+
"target_person": {"id": "alice", "type": "schema:Person"},
79+
"target_repository": {
80+
"id": "owner/repo",
81+
"type": "schema:SoftwareSourceCode",
82+
},
83+
}
84+
85+
6486
def test_llm_contribution_agent_validates_payload_and_exposes_model_metadata(
6587
load_schema,
6688
) -> None:
@@ -71,10 +93,7 @@ def test_llm_contribution_agent_validates_payload_and_exposes_model_metadata(
7193
agent.run(
7294
{
7395
"contribution_seed": "owner/repo",
74-
"known_persons": [{"id": "alice", "type": "schema:Person"}],
75-
"known_repositories": [
76-
{"id": "owner/repo", "type": "schema:SoftwareSourceCode"},
77-
],
96+
**_person_and_repo_context(),
7897
},
7998
_providers(),
8099
),
@@ -138,7 +157,12 @@ def test_llm_contribution_agent_records_strict_schema_warnings() -> None:
138157
payload["pulse:firstContributionDate"] = "not-a-date"
139158
agent = LLMContributionAgentV2(llm_runtime=_FakeLLMRuntime(payload))
140159

141-
result = asyncio.run(agent.run({"contribution_seed": "owner/repo"}, _providers()))
160+
result = asyncio.run(
161+
agent.run(
162+
{"contribution_seed": "owner/repo", **_person_and_repo_context()},
163+
_providers(),
164+
),
165+
)
142166

143167
assert result.warnings, "Expected strict-schema warnings but got none"
144168
assert any("pulse:firstContributionDate" in warning for warning in result.warnings)

0 commit comments

Comments
 (0)