Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/codex-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inferrsi/
assets/infermatrix-icon.png
skills/inferrsi/SKILL.md
skills/inferrsi/scripts/inferrsi.py
skills/inferrsi-jiusi/SKILL.md
skills/inferrsi-jiusi/agents/openai.yaml
skills/inferrsi-jiusi/references/
runtime/manifest.json
runtime/inferrsi/
LICENSE
Expand Down Expand Up @@ -89,6 +92,37 @@ interpreter. Commands that parse skill frontmatter, including direct reads of
checkout skills, require PyYAML in the selected interpreter.
Image validators and target engines retain their own optional dependencies.

## Optional Jiusi interview

Explicitly invoke `$inferrsi-jiusi` to clarify an optimization task before
starting experiments. Its display name is **InferRSI-Jiusi**. For example:

> $inferrsi-jiusi Optimize this engine's throughput. First clarify my workload,
> quality requirements, implementation preferences, prior attempts and budget.

The entry uses a bundled grilling-style interview: the Agent inspects accessible
facts, asks independent decisions together, waits for your answers, then follows
the decisions those answers unlock. It reuses information you already supplied.
Before execution, it presents a task brief distinguishing constraints,
user-reported experience, hypotheses and unknown measurements, and asks you to
confirm it. Confirmed decisions feed the existing InferRSI task and experiment
protocol. You can correct the brief, delegate a choice, cancel or explicitly
switch to ordinary InferRSI.

This skill sets `policy.allow_implicit_invocation: false` in its
`agents/openai.yaml`: ordinary InferRSI requests and setup keep the original
entry. Use the explicit skill selector/mention rather than relying on a plain
text name to activate Jiusi. See the
[Codex invocation policy](https://learn.chatgpt.com/docs/build-skills#optional-metadata).
The ZIP carries the interview guide, its source attribution and MIT license;
no separate grilling installation is needed. This optional entry is specific to
the Codex bundle and reuses its existing runtime and launcher.

Packaging checks establish resource inclusion, invocation metadata and isolated
launcher operation. Client discovery, interview behavior and any improvement in
optimization efficiency need their own host-level validation; a passing package
check does not establish faster convergence.

## MindIE knowledge

The agent assesses each question independently and consults MindIE only when
Expand Down
73 changes: 73 additions & 0 deletions plugins/inferrsi/skills/inferrsi-jiusi/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: inferrsi-jiusi
description: Explicitly requested InferRSI-Jiusi interview to clarify an inference optimization task before running InferRSI. Use only when the user invokes this entry for the current task.
---

# InferRSI-Jiusi

Interview the user about the decisions that will shape an inference experiment,
then hand the confirmed task to [InferRSI](../inferrsi/SKILL.md). This entry is
opt-in for the current task; ordinary InferRSI keeps its existing workflow.
Discussing or quoting this entry's name is not an instruction to run it.

## Interview before execution

Read the bundled [grilling procedure](references/grilling.md) before asking the
first round. It supplies the decision tree, dependency-aware rounds and
completion rule; a separate grilling skill installation is unnecessary.

Start with the user's request, prior answers and accessible repository facts.
Inspect existing configurations, benchmark entrypoints and quality checks to
avoid asking the user for facts you can establish. Keep repository observations,
user-reported experience, preferences and unverified hypotheses distinct.
Follow the original entry's primary-skill selection before an inference evidence
search; reading guidance is preparation, not permission to execute it.

During the interview, use read-only investigation and discuss a proposed plan.
Candidate edits, campaign creation, measurements, service launches and device
work wait for the user's confirmation of the task brief. Resource rules still
apply after confirmation. If facts need measurements, record a calibration step
with its scope and budget rather than inventing the result.

Use the user's language. Ask each round's independent questions together and
wait for the answers before asking questions that depend on them. Include a
recommended answer and its tradeoff when evidence supports one. A recommendation,
silence or elapsed time is never a submitted answer. Reuse settled answers and
explicit delegation such as "you decide" instead of asking them again.

## Confirm the task

When the grilling procedure's completion rule is satisfied, use the
[brief template](references/brief-template.md) to state the agreed task in the
conversation. Adapt its fields to the actual deliverable. Preserve unknown
measurements and distinguish an approved diagnostic step from a qualified
optimization result. Ask the user to confirm or correct this concrete brief.

If the user corrects it, reopen the affected decisions and their dependents.
If the user explicitly switches to ordinary InferRSI or asks to skip the
remaining interview, honor that direction and carry settled answers forward;
ordinary InferRSI still resolves its own required inputs. Cancellation ends this
entry. Invocation does not create a persistent preference for later tasks.

## Continue through InferRSI

After confirmation, continue through [the original entry](../inferrsi/SKILL.md),
reading it now if it was not already loaded for read-only preparation. Use the
confirmed decisions. Resolve its existing launcher at
`../inferrsi/scripts/inferrsi.py` relative to this skill directory, while keeping
the working directory in the user's target workspace. The original entry's
`scripts/inferrsi.py` reference is relative to its own directory.

Carry the brief into the existing task instructions and protocol inputs as
appropriate. The brief is a record of intent; actual measurement and quality
scripts must implement the accepted checks. Preserve the original primary-skill
selection, knowledge condition, candidate assessment and independent final
evaluation. A frozen benchmark's task and gates remain the benchmark's inputs;
the interview may resolve allowed configuration, not rewrite that task.

Run the interview once for this task. Revisit decisions when a material goal or
constraint changes; follow the existing workflow for changed frozen protocols.
Retain useful user experience as attributed context and test its applicability
with measurements. Report actual execution and quality evidence through the
original workflow. Faster convergence is a hypothesis, not a result of merely
completing the interview.
5 changes: 5 additions & 0 deletions plugins/inferrsi/skills/inferrsi-jiusi/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface:
display_name: "InferRSI-Jiusi"
short_description: "Clarify optimization goals before running RSI"
policy:
allow_implicit_invocation: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Confirmed task brief

Use the applicable fields to summarize the decisions in the conversation.
Keep prior answers and evidence links; mark missing facts as unknown. This is a
human-readable handoff to existing task/protocol inputs, not a new runtime schema.

- **Requested deliverable:**
- **Target:** repository, framework, baseline, model/revision, hardware and runtime
facts, with sources where inspected.
- **Workload and measurement scope:** representative inputs, load and metric.
- **Objective and tradeoffs:** priority, service constraints and acceptance gates;
identify supplied gates and any calibration needed to derive missing ones.
- **Quality contract:** oracle/checks, precision, acceptable output changes and
current validation gaps.
- **Permitted changes and preferences:** editable areas, deployment/dependency
limits, upstream and maintenance requirements.
- **User-reported experience:** prior attempts, observed conditions, evidence and
retry conditions; separate unsupported explanations from observations.
- **Hypotheses and unknowns:** what needs measurement or verification.
- **Resources and stopping:** devices, time/cost, stop conditions and final retest
allowance.
- **Proposed next step:** bounded diagnostic/calibration or experiment, its inputs
and required checks.
- **Delegated decisions:** choices the user delegated and the choices made.

Ask the user to confirm this brief or identify corrections. Retain the confirmed
scope for the current task; carry it into the original InferRSI workflow.
21 changes: 21 additions & 0 deletions plugins/inferrsi/skills/inferrsi-jiusi/references/grilling-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Matt Pocock

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions plugins/inferrsi/skills/inferrsi-jiusi/references/grilling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Grilling for an inference task

Adapted from Matt Pocock's [grilling skill](https://github.com/mattpocock/skills/blob/abeeaf95660ba9e8b7c753eb38f441ca707a8823/skills/productivity/grilling/SKILL.md),
revision `abeeaf95660ba9e8b7c753eb38f441ca707a8823`, under the
[MIT license](grilling-LICENSE). This adaptation keeps its decision tree,
frontier, rounds, agent-led fact finding and explicit confirmation, and bounds
the interview to decisions needed for the requested inference task.

## Build the decision tree

Map the task as decisions and their dependencies. The frontier contains only
decisions whose prerequisites are already settled. Ask that frontier in one
round, then wait for the user's answers and recompute it. A question depending
on an unanswered question belongs in a later round. Avoid a fixed questionnaire
or a fixed number of rounds; ask what can change the experiment or its acceptance.

Use these topics where they affect the user's task:

| Topic | Decisions worth resolving |
| --- | --- |
| Deliverable and target | Existing engine or another requested deliverable; fixed framework or alternatives allowed; target checkout and baseline |
| Workload | Representative requests, concurrency or arrival pattern, input/output sizes, modalities and important tail cases |
| Objective | Latency, throughput, memory or cost; priority among them; required service constraints and measurement scope |
| Quality | Existing oracle, precision, allowed approximations and what output changes are acceptable |
| Search space | Editable areas, dependency or deployment changes, upstream compatibility and maintenance preferences |
| Prior experience | Attempts already made, their conditions and evidence, failure reasons and conditions that could justify a retry |
| Budget and delivery | Allowed resources, time or cost, stopping conditions, final retest allowance and desired deliverables |

Discover repository and environment facts yourself. When delegation is available,
use a fresh-context subagent for independent fact finding; otherwise inspect
directly. An unresolved investigation is an unsettled prerequisite: continue
with independent questions while its dependent questions wait. Discovery does
not reserve a device or authorize a benchmark.

Treat a user's technical diagnosis as a hypothesis unless supporting evidence
establishes it. Treat an explicit user constraint as a constraint. If a new
answer contradicts an earlier one, surface the conflict before choosing between
them. Explain a recommended answer's reason and tradeoff so the user can disagree.

## Ask a round

Number the questions, explain their consequence, and give a supported
recommendation. For example:

```text
Q1 — Objective: Should we maximize throughput while preserving the current
tail-latency requirement? If so, what requirement and traffic cohort apply?
Recommendation: keep the existing service requirement, then optimize throughput
inside it. This makes a throughput improvement usable at the target load.
```

Use the host's question tool when suitable, or ask in the conversation. Wait for
the user's actual answer. A partial answer settles only the decisions it covers.
Explicitly delegated choices are settled with the recorded delegation and the
agent's resulting choice. A measurement still to be made remains unknown.

## Reach a shared understanding

Finish when no unresolved user decision can change the proposed first diagnostic
or experiment, quality contract, permitted search space or resource budget.
Every relevant branch must be settled, explicitly delegated, or deferred with a
reason showing that it does not affect the proposed next step. Unknown empirical
facts may become bounded calibration work; unknown acceptance thresholds are
not guessed. If quality cannot yet be assessed, state a diagnostic-only scope
and what evidence is needed before an optimization can be accepted.

Return to the entry's brief-and-confirm step. The user's confirmation of the
brief completes the interview and permits the existing workflow to proceed
within that scope. Later explicit user corrections, cancellation or a request
to switch modes take precedence over this procedure.
48 changes: 48 additions & 0 deletions tests/test_codex_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from urllib.parse import unquote, urlsplit

import pytest
import yaml

from inferrsi.knowledge.catalog import _split_skill_metadata
from tools.build_codex_plugin import build_plugin
Expand Down Expand Up @@ -338,6 +339,9 @@ def test_archive_contains_only_one_standalone_plugin(tmp_path):
assert not any("marketplace" in name or ".agents" in name for name in names)
metadata = json.loads(archive.read("inferrsi/plugin.json"))
assert metadata["$schema"] == "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json"
assert metadata["extensions"]["com.openai"]["onboardingSkill"] == (
"./skills/inferrsi/SKILL.md"
)
interface = metadata["extensions"]["com.openai"]["interface"]
assert len(interface["shortDescription"]) <= 30
assert metadata["author"]["name"] == interface["developerName"] == "InferMatrixLab"
Expand All @@ -354,6 +358,50 @@ def test_archive_contains_only_one_standalone_plugin(tmp_path):
assert json.loads(info.stdout)["content_sha256"] == manifest["content_sha256"]


def test_codex_jiusi_bundle_has_explicit_entry_and_resolvable_handoff(distribution, tmp_path):
jiusi = distribution / "skills/inferrsi-jiusi"
if not (distribution / "plugin.json").is_file():
# WorkSwarm has its own template and retains its existing entrypoints.
assert not jiusi.exists()
return

source = PROJECT / "plugins/inferrsi/skills/inferrsi-jiusi"
required = {
"SKILL.md", "agents/openai.yaml", "references/grilling.md",
"references/brief-template.md", "references/grilling-LICENSE",
}
bundled = {path.relative_to(jiusi).as_posix() for path in jiusi.rglob("*") if path.is_file()}
assert required <= bundled
for name in bundled:
assert (jiusi / name).read_bytes() == (source / name).read_bytes()

header = (jiusi / "SKILL.md").read_text(encoding="utf-8").split("---", 2)[1]
assert yaml.safe_load(header)["name"] == "inferrsi-jiusi"
configuration = yaml.safe_load((jiusi / "agents/openai.yaml").read_text(encoding="utf-8"))
assert configuration["interface"]["display_name"] == "InferRSI-Jiusi"
assert configuration["policy"]["allow_implicit_invocation"] is False

# Resolve every local resource from its owning document after ZIP extraction.
# This catches references that only work inside the source checkout.
for document in jiusi.rglob("*.md"):
for target in re.findall(r"\[[^\]]*\]\(([^\s)]+)\)", document.read_text(encoding="utf-8")):
link = urlsplit(target)
if not link.scheme and not link.netloc and link.path:
resolved = (document.parent / unquote(link.path)).resolve()
assert resolved.is_relative_to(distribution.resolve())
assert resolved.is_file(), f"Broken Jiusi resource: {document.name}: {target}"

launcher = (jiusi / "../inferrsi/scripts/inferrsi.py").resolve()
assert launcher == (distribution / "skills/inferrsi/scripts/inferrsi.py").resolve()
(tmp_path / "inferrsi.py").write_text("raise RuntimeError('wrong import')", encoding="utf-8")
result = subprocess.run(
[sys.executable, "-I", "-S", "-X", "utf8", str(launcher), "--plugin-info"],
cwd=tmp_path, capture_output=True, text=True, encoding="utf-8", timeout=45,
)
assert result.returncode == 0, result.stderr
assert json.loads(result.stdout)["runtime"] == "bundled"


@pytest.fixture(scope="module", params=["codex", "workswarm"])
def release_distribution(tmp_path_factory, request):
host = request.param
Expand Down
Loading