Skip to content

Add claude-api Files upload regression example - #14

Open
GBX-Max1220 wants to merge 3 commits into
Tencent:mainfrom
GBX-Max1220:examples/claude-api-files-purpose
Open

GBX-Max1220 wants to merge 3 commits into
Tencent:mainfrom
GBX-Max1220:examples/claude-api-files-purpose

Conversation

@GBX-Max1220

@GBX-Max1220 GBX-Max1220 commented Sep 26, 2026 •

Copy link
Copy Markdown

Summary

Add a reproducible SkillHone case for stale Files API upload guidance in Anthropic's claude-api Skill.

What changed

  • Fetch the pinned pre-fix upstream commit 5128e1865d670f5d6c9cef000e6dfc4e951fb5b9.
  • Verify the upstream Skill tree and license before generating the fixture.
  • Add a static regression test for unsupported purpose parameters in upload examples.
  • Record the upstream repair commit: d230a6dd6eb1a0dbee9fec55e2f00a96e28dff81.

Reproduction

python3 examples/claude-api-files-purpose/prepare_fixture.py /tmp/claude-api-files-purpose
python3 /tmp/claude-api-files-purpose/.test/test_files_upload_contract.py
git -C /tmp/claude-api-files-purpose apply repair.patch
python3 /tmp/claude-api-files-purpose/.test/test_files_upload_contract.py

The baseline test fails with exit 1 and reports four unsupported purpose parameters:

  • curl/managed-agents.md code block 15: multipart purpose field
  • shared/managed-agents-client-patterns.md code block 8: SDK purpose argument
  • shared/managed-agents-environments.md code block 3: SDK purpose argument
  • typescript/managed-agents/README.md code block 11: SDK purpose argument

After applying the generated repair.patch to the fixture, the regression test passes (exit 0).

Validation and results

  • pnpm test: 31 passed, 0 failed.
  • python3 skills/skillhone/scripts/quality/static_check.py skills/skillhone: passed.
  • python3 skills/skillhone/scripts/quality/static_check.py skills/skillhone-auto-optimization: passed.
  • gitleaks dir . --no-banner --redact: no leaks found.
  • gitleaks git . --no-banner --redact: no leaks found (22 commits).
  • git diff --check: passed.
  • Fixture contract: baseline failed (exit 1) on the four findings above; repaired temporary fixture passed (exit 0).

Effect and limits

Changes are limited to examples/claude-api-files-purpose/. No SkillHone core files changed. The test is a static documentation contract; it does not call Anthropic's API or verify live server behavior.

Review checklist

  • The linked Issue and reproduction are clear.
  • Focused repository tests pass, with counts reported above.
  • The diff contains only files needed for this fix.
  • I ran git diff --check.
  • I ran gitleaks or an equivalent credential scan.
  • This change contains no API keys, private prompts, private traces, or generated local state.
  • No generated repair was pushed or merged automatically.
  • A user has reviewed the Issue, tests, commits, and changed files before merge.

GBX-Max1220 and others added 3 commits September 26, 2026 23:59
Adds examples/claude-api-files-purpose, pinning anthropics/skills at
5128e1865d670f5d6c9cef000e6dfc4e951fb5b9 (the commit before the upstream
Files API repair) and generating a deterministic static contract test that
detects the unsupported `purpose` parameter in Files upload examples.

Upstream repair recorded: d230a6dd6eb1a0dbee9fec55e2f00a96e28dff81.

Baseline contract test fails on four examples (curl/managed-agents.md,
shared/managed-agents-client-patterns.md, shared/managed-agents-environments.md,
typescript/managed-agents/README.md); removing the four `purpose` arguments
makes it pass.

The contract test is structural: it does not call Anthropic's API, does not run
upstream code, and does not assert server error wording or live behavior.

Scope: examples/ only. No SkillHone core changes.
…s case

The case could be reproduced but not verified: confirming that the contract
test is satisfiable by the real fix meant hand-editing the four reported
examples. prepare_fixture.py now emits repair.patch into the fixture at
preparation time, taken from upstream repair
d230a6dd6eb1a0dbee9fec55e2f00a96e28dff81.

Before writing it, the script fetches that commit at depth 2 and checks that
its parent is the pinned defect commit
5128e1865d670f5d6c9cef000e6dfc4e951fb5b9, that its skills/claude-api tree is
284049f382b3c2b1989353637e0b3848dad0f09f, and that it changes exactly the
four Skill files the test reports. After committing the fixture it checks the
patch still applies. The diff is produced with --relative=skills/claude-api so
"git apply repair.patch" works from the fixture root.

Verified: the baseline test fails on the same four examples and passes after
the patch, with the four patched files byte-identical to the upstream repair
blobs and the remaining Skill files unchanged.

The patch is generated into the fixture only; no upstream content is added to
this repository. README and the generated PROVENANCE.md both record that it is
a verification aid an evaluation run should withhold from the system under
test.

Scope: examples/claude-api-files-purpose/ only. No SkillHone core changes.
prepare_fixture.py wrote the materialized Skill tree straight into the
user-supplied destination, so a check that failed afterwards stranded a
half-built fixture there, and the next run then refused to touch it.

Everything now happens in a staging directory beside the destination: fetch,
tree, parentage and scope verification, patch generation, the fixture's own
commit, and the git apply --check. Only once all of it passes does a
same-filesystem rename publish the fixture, and the finally block removes the
staging tree on any failure, including an interrupt.

Consequence: the destination's parent must already exist, since nothing is
created before the build has succeeded.

Verified against the real upstream commit: the happy path still fails the
baseline on the same four examples and passes after git apply repair.patch;
injected download, tree, parentage, scope and apply-check failures each leave
no destination and no staging behind; SIGINT mid-fetch leaves nothing and the
same path reruns cleanly; a destination placed on a different filesystem than
TMPDIR still publishes by rename.

Scope: examples/claude-api-files-purpose/prepare_fixture.py only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant