Repository navigation
feat(eval-author): implement the discover command #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aleckhoury
merged 16 commits into
main
from
ase-677-eval-author-discover-command/akhoury
Aug 18, 2026
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
28fe43c
feat(eval-author): implement the discover command
aleckhoury 4a49ab2
test(eval-author): group the discover tests under tests/discover
aleckhoury d7978da
fix(eval-author): point discovery at the repo's own Harbor config
aleckhoury 72549f7
refactor(eval-author): drop two unused entry points from the validati…
aleckhoury 53c9ed6
feat(eval-author): make the discovery scout opt-in as --fix
aleckhoury 383ae39
refactor(eval-author): drop the platform and backend flags from discover
aleckhoury 2726e7d
fix(eval-author): harden discover's reuse gate and sharpen its findings
aleckhoury 66f5efe
refactor(eval-author): rename --fix to --dangerously-fix and warn in …
aleckhoury d1b1e2f
refactor(eval-author): cut discover back to what it can prove
aleckhoury bbd37af
fix(eval-author): stop discover from reading the optimizer's own job …
aleckhoury 695de10
fix(eval-author): run the round trip through the Harbor the ladder used
aleckhoury c932fd5
fix(eval-author): record the search path the agent import actually needs
aleckhoury 14bc1ce
Merge remote-tracking branch 'origin/main' into ase-677-eval-author-d…
aleckhoury 2f57011
refactor(eval-author): reduce discover to repository preflight
aleckhoury bc6a550
feat(eval-author): discover hosted agent doctrine
aleckhoury 22e9d06
feat(eval-author): discover every Harbor config
aleckhoury File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
plugins/nemo-eval-author/src/nemo_eval_author_plugin/discovery/agent.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """A bounded scout that proposes a config when the ladder cannot get one. | ||
|
|
||
| Only reached when validation failed on something a look around the repo could plausibly | ||
| settle: which directory is the dataset rather than the single-task template, what the | ||
| wrapper's class is actually called, which of two plausible entrypoints is the real one. | ||
|
|
||
| The scout's output is a proposal and never a result. Whatever it returns goes back through | ||
| the ladder from the schema rung, and a config it touched is persisted only if Harbor then | ||
| accepts it. That ordering is the whole reason a later, weaker model can trust the artifact: | ||
| the strong model is allowed to guess, and Harbor decides whether the guess was right. | ||
|
|
||
| Importing this module builds an LLM client, because ``Agent`` binds ``llm`` while the class | ||
| body executes. The CLI therefore imports it inside the command body rather than at module | ||
| scope, so ``nemo eval-author discover`` on a repo that needs no scouting works with no | ||
| ``AUTHOR_*`` credentials at all. | ||
| """ | ||
|
|
||
| import json | ||
| import logging | ||
| from collections.abc import Awaitable, Callable | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| # Populates EXPERIMENTALIST_* from AUTHOR_*, which the Experimentalist modules imported | ||
| # below read while their class bodies execute. Must stay ahead of them; isort keeps it there. | ||
| import nemo_eval_author_plugin._env_bridge # noqa: F401 | ||
| from nemo_eval_author_plugin.discovery.models import CandidateConfig, ConfigSource, Finding | ||
| from nemo_eval_author_plugin.discovery.validate import ValidationOutcome, run_ladder | ||
| from nemo_eval_author_plugin.model_config import get_smart_model | ||
| from nemo_experimentalist_plugin.experimentalist.components.tools import GuardedShellTools | ||
| from nooa import Agent, CodeActStrategy, strategy | ||
| from nooa.config import CodeActConfig | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| _GROUP = "scout" | ||
|
|
||
| # The rungs a look at the filesystem could plausibly resolve. A backend preflight failure | ||
| # means Docker is not running, and no amount of reading the repo fixes that. | ||
| _SCOUTABLE_RUNGS = frozenset({"schema", "resolution", "tasks", "agent", "config-source"}) | ||
|
|
||
| ProposeFn = Callable[[CandidateConfig, list[Finding], Path], Awaitable["ScoutProposal"]] | ||
|
|
||
|
|
||
| class ScoutProposal(BaseModel): | ||
| """A config the scout believes will validate, plus its reasoning.""" | ||
|
|
||
| config: dict[str, Any] = Field(description="A complete Harbor job config payload, not a patch.") | ||
| rationale: str = Field(description="What was inspected and why this config follows from it.") | ||
| changed: list[str] = Field(default_factory=list, description="The keys that differ from the input config.") | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
| class DiscoveryScout(Agent, llm=get_smart_model()): | ||
| """Reads an agent repository to work out how its Harbor evaluations are meant to run.""" | ||
|
|
||
| def __init__(self, repo_root: Path, **kwargs: Any) -> None: | ||
| super().__init__(**kwargs) | ||
| self.repo_root = repo_root | ||
| self.shell = GuardedShellTools(cwd=repo_root) | ||
|
|
||
| @strategy(CodeActStrategy(config=CodeActConfig(max_iterations=20, cell_timeout=60.0))) | ||
| async def propose_config(self, candidate: str, blocking: str) -> ScoutProposal: | ||
| """Work out the Harbor job config this repository actually intends. | ||
|
|
||
| A candidate config was assembled from the repository and rejected by Harbor's own | ||
| validators. Use the shell to inspect the repository and return a config that will | ||
| pass. | ||
|
|
||
| Args: | ||
| candidate: The rejected Harbor job config, as JSON. | ||
| blocking: The validation failures, each naming the Harbor call that produced it. | ||
|
|
||
| Returns: | ||
| ScoutProposal: A complete config payload, the keys changed, and the reasoning. | ||
|
|
||
| Ground every change in something read from the filesystem: a directory that holds | ||
| `task.toml` files, a class definition in a wrapper module, a path named in a config | ||
| or README. Do not invent dataset paths, task names, agent import paths, or model | ||
| names, and do not add fields the repository gives no evidence for. | ||
|
|
||
| A config returned unchanged with the rationale explaining what is missing is a | ||
| useful answer. A plausible-looking guess is not: this proposal is revalidated | ||
| against Harbor, and a wrong guess costs another round trip while an honest "the | ||
| repository does not say" tells the user what to fix. | ||
| """ | ||
|
|
||
| async def scout(self, candidate: CandidateConfig, blocking: list[Finding]) -> ScoutProposal: | ||
| summary = "\n".join( | ||
| f"- {finding.name}: {finding.message}" + (f" (from {finding.harbor_call})" if finding.harbor_call else "") | ||
| for finding in blocking | ||
| ) | ||
| return await self.propose_config(json.dumps(candidate.data, indent=2, sort_keys=True), summary) | ||
|
|
||
|
|
||
| def is_scoutable(outcome: ValidationOutcome) -> bool: | ||
| """Whether any failure is the kind reading the repo could plausibly settle.""" | ||
| return any(finding.name in _SCOUTABLE_RUNGS for finding in outcome.findings if finding.status == "fail") | ||
|
|
||
|
|
||
| async def _ask_the_scout(candidate: CandidateConfig, blocking: list[Finding], repo_root: Path) -> ScoutProposal: | ||
| return await DiscoveryScout(repo_root=repo_root).scout(candidate, blocking) | ||
|
|
||
|
|
||
| async def attempt_repair( | ||
| candidate: CandidateConfig, | ||
| outcome: ValidationOutcome, | ||
| repo_root: Path, | ||
| propose: ProposeFn = _ask_the_scout, | ||
| ) -> tuple[CandidateConfig, ValidationOutcome, list[Finding]]: | ||
| """Let the scout propose a config, then make Harbor judge it. | ||
|
|
||
| Returns the proposal and its validation only if the ladder is happier with it than | ||
| with what we had. "Happier" means runnable, not merely different: a proposal that | ||
| trades one failure for another is noise, and keeping the original at least leaves the | ||
| user with failures traceable to their own repo rather than to a language model. | ||
|
|
||
| ``propose`` is a parameter so this containment logic can be tested without a model. | ||
| It is the part worth testing: nooa refuses to let a test attach a method to an agent | ||
| class, and the interesting behavior here is what happens to a proposal, not how one is | ||
| produced. | ||
| """ | ||
| blocking = [finding for finding in outcome.findings if finding.status == "fail"] | ||
| try: | ||
| proposal = await propose(candidate, blocking, repo_root) | ||
| except Exception as exc: | ||
| logger.debug("discovery scout failed", exc_info=True) | ||
| return ( | ||
| candidate, | ||
| outcome, | ||
| [ | ||
| Finding( | ||
| name="scout", | ||
| group=_GROUP, | ||
| status="warn", | ||
| message=f"The scout could not run: {type(exc).__name__}: {exc}", | ||
| hint="Set AUTHOR_API_KEY and AUTHOR_BASE_URL, or pass --no-deep to skip this step.", | ||
| provenance="inference", | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| if proposal.config == candidate.data: | ||
| return ( | ||
| candidate, | ||
| outcome, | ||
| [ | ||
| Finding( | ||
| name="scout", | ||
| group=_GROUP, | ||
| status="warn", | ||
| message=f"The scout found nothing in the repo to change: {proposal.rationale}", | ||
| provenance="inference", | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| proposed = CandidateConfig( | ||
| data=proposal.config, | ||
| source=ConfigSource( | ||
| kind=candidate.source.kind, | ||
| detail=f"{candidate.source.detail}, then adjusted by the discovery scout", | ||
| path=candidate.source.path, | ||
| # Even when the source was the repo's own config file, the artifact can no | ||
| # longer point at it: what Harbor accepted is the scout's version. | ||
| adjusted=True, | ||
| ), | ||
| ) | ||
| revalidated = await run_ladder(proposed, repo_root) | ||
| changed = ", ".join(proposal.changed) if proposal.changed else "unspecified keys" | ||
|
|
||
| if not revalidated.runnable: | ||
| return ( | ||
| candidate, | ||
| outcome, | ||
| [ | ||
| Finding( | ||
| name="scout", | ||
| group=_GROUP, | ||
| status="warn", | ||
| message=f"The scout proposed changes to {changed}, and Harbor still rejected the result", | ||
| hint=f"Its reasoning: {proposal.rationale}", | ||
| provenance="inference", | ||
| ) | ||
| ], | ||
| ) | ||
|
|
||
| return ( | ||
| proposed, | ||
| revalidated, | ||
| [ | ||
| Finding( | ||
| name="scout", | ||
| group=_GROUP, | ||
| status="pass", | ||
| message=f"The scout changed {changed}, and Harbor accepted the result", | ||
| hint=f"Its reasoning: {proposal.rationale}", | ||
| provenance="inference", | ||
| ) | ||
| ], | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.