Repository navigation
fix: update the default model, quote workflow inputs, cut at words - #17
Merged
Merged
Conversation
The default drafting model was the dated snapshot claude-sonnet-4-20250514, written in config.py, twice more in composer.py, in .env.example and in the README. The API now returns 404 for it, and the scheduled weekly digest failed on 2026-07-13 with that error. The workflow had no way to change the model without a code change. Changes: - config.py names the default once, DEFAULT_MODEL = "claude-sonnet-5-5". An empty HERALD_DEFAULT_MODEL falls back to it, so an unset workflow variable can't blank the model. - compose() uses the default_model setting when no model is passed, instead of repeating the literal. - compose() reads text blocks by type. Current models think by default, so a reply can start with a thinking block, and content[0].text raised AttributeError. max_tokens goes from 2000 to 16000 because thinking counts toward it. A reply with no text raises ComposeError, which the CLI prints as one line. - The consilium council keeps a separate Claude seat, claude-sonnet-4-6, because consilium reads the first reply block as text. The README says so. - The weekly-digest workflow passes vars.HERALD_DEFAULT_MODEL to herald. - .env.example no longer pins a model; the README names the new default. - tests/test_no_retired_models.py fails if shipped code, docs or workflows name a retired model id. Ledger: B263 Signed-off-by: abrichr <richard.abrich@mldsai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "Determine content type" step wrote ${{ inputs.content_type }} and
${{ inputs.days }} straight into its run script, and the publish step
did the same with the step outputs. GitHub substitutes those
expressions before the shell starts, so a dispatch with days set to
7"; echo INJECTED; echo " ran the injected command. Anyone who can
dispatch the workflow could run commands in the publish step, which
holds the posting secrets.
Changes:
- Both steps read inputs and outputs from env: and quote them.
- The params step accepts only digest, release or spotlight and a whole
number of days, and stops with an error otherwise, so a newline can't
add a second output either.
- The dry-run flag also comes from env.
- tests/test_workflows.py fails if any run: script in any workflow
contains an expression. It also runs the params step in bash, after
substituting expressions the way the runner does, with injection
attempts and with valid inputs.
Ledger: B268
Signed-off-by: abrichr <richard.abrich@mldsai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main already fixed the README install line, the release collector's JSON parsing and the dry-run input. Three defects were left. - X, LinkedIn and Discord drafts were cut at a fixed number of Python characters, inside a word or a link and with no ellipsis. For X the count was also wrong: a long link that X counts as 23 was cut, and 240 CJK characters (420 by X's count) were sent as they were. A new shorten() helper in platforms/base.py cuts after the last whole word that fits and adds an ellipsis. The X publisher measures with x_weighted_length, the counter herald post already uses. The composer's plain-text fallback no longer cuts the X draft at 280 first, and cuts the summary at a word. - When gh failed (not installed, timed out, signed out, or not JSON), the collectors returned an empty list without a word, so a failed run looked like a quiet week. They now print the reason on stderr. - The weekly-digest workflow titled every Discord embed "Weekly Digest", including release and spotlight runs. The params step now sets the title from the content type. The README describes the new shortening. A test checks that every README install command uses the GitHub URL, since the package isn't on PyPI. Not changed: re-running publish after a partial failure still posts again to the platforms that succeeded. That needs a decision on whether publish should keep a ledger like herald post. Ledger: B250 Signed-off-by: abrichr <richard.abrich@mldsai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compose() fell through to its plain-text fallback whenever the reply wasn't valid JSON. A reply cut off by max_tokens or a refusal is usually half-written JSON, so the fallback made that fragment the draft for Discord, X and LinkedIn, and `herald publish` would post it. Current models think by default and thinking counts toward max_tokens, so a cut-off reply is more likely than before. compose() now raises ComposeError when the stop reason is max_tokens or refusal, and the CLI prints it as one line. The composer tests now check the exception by name, so on code without ComposeError they fail on the behavior (an AttributeError, or no error) rather than on an import. Ledger: B263 Signed-off-by: abrichr <richard.abrich@mldsai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
x_weighted_length counted a link followed directly by U+2026 as one link of 23. X ends the link before the ellipsis and counts the ellipsis as 2. `herald publish` adds an ellipsis when it shortens an X draft, so a draft whose last whole word was a link could be sent at 281 by X's count, and X would refuse it. The ellipsis now ends a link, like the other trailing punctuation. The count only goes up, so `herald post` refuses at least everything it refused before. Ledger: B250 Signed-off-by: abrichr <richard.abrich@mldsai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_config reads the default from the settings field, so on the old code the blank-variable test fails because the model is blank. - The CLI test runs the real compose() with a reply that holds only a thinking block, which used to raise AttributeError. - The workflow injection payloads print INJECTED-42 only when the shell evaluates them, and the tests check that marker first, in the output file too. - The dry-run test checks that the publish script passes DRY_RUN_FLAG. - The model-id guard calls the Sonnet 4 snapshot deprecated, as Anthropic's model list does, and adds two ids past their retirement date. The config comment no longer claims a 404 that the expired run log can't confirm. Ledger: B263, B268 Signed-off-by: abrichr <richard.abrich@mldsai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This branch fixes three problems in drafting and posting.
herald publishcut drafts in the middle of words and links, and counted X posts in Python characters instead of X's weighted count.Fixes
claude-sonnet-4-20250514, a deprecated snapshot written in five places. The workflow had no way to change it.config.DEFAULT_MODEL = "claude-sonnet-5-5"is the only default. A blankHERALD_DEFAULT_MODELfalls back to it,compose()reads the setting, and the workflow passesvars.HERALD_DEFAULT_MODEL.tests/test_config.py,tests/test_no_retired_models.py,test_compose_without_model_uses_the_setting,test_publish_step_lets_a_repository_variable_set_the_modelcompose()readcontent[0].text, which raisesAttributeErroron a thinking block.max_tokensgoes from 2000 to 16000, because thinking counts toward it. A reply with no text raisesComposeError, which the CLI prints as one line.test_compose_reads_text_after_a_thinking_block,test_compose_without_text_raises,test_reply_without_text_prints_one_linemax_tokensor a refusal went to the plain-text fallback, so half-written JSON became the draft for every platform.compose()raisesComposeErrorfor those two stop reasons.test_compose_rejects_an_unfinished_reply(2 cases)inputs.days,inputs.content_typeand step outputs straight intorun:scripts. A dispatch withdaysset to7"; echo ...; echo "ran the command.env:and are quoted. The params step accepts onlydigest,releaseorspotlightand a whole number of days, and stops otherwise.test_run_scripts_contain_no_expressions,test_params_step_rejects_days_that_are_not_a_number(6 cases),test_params_step_rejects_an_unknown_content_type,test_publish_step_passes_dry_run_to_heraldshorten()inplatforms/base.pycuts after the last whole word that fits and adds…. The X publisher measures withx_weighted_length.TestShorten(3), the word-boundary, CJK and long-link tests intests/test_platforms.py,test_non_json_fallback_does_not_cut_mid_wordx_weighted_lengthcounted a link followed by…as one link of 23. X ends the link before the ellipsis and counts the ellipsis as 2, so a shortened post that ended in a link could go out at 281.…now ends a link, like other trailing punctuation. The count can only go up, soherald poststill refuses everything it refused before.test_ellipsis_after_a_link_is_not_part_of_it,test_publish_counts_an_ellipsis_after_a_linkghfailed, the collectors returned an empty list without a word, so a failed run looked like a quiet week.test_collect_releases_failure_says_why,test_collect_prs_without_gh_says_sotest_params_step_titles_a_spotlight,test_publish_step_titles_the_embed_from_the_content_typeNot fixed here
herald publishagain after a partial failure posts again to the platforms that already succeeded. This needs a decision: shouldpublishkeep an append-only ledger likeherald postand skip a platform that already got the same draft?claude-sonnet-4-6. consilium readscontent[0].textand can passtemperature, so a model that thinks by default would break it. That's a follow-up for openadapt-consilium. Thegpt-4oseat wasn't checked.anthropicSDK (0.84.0) doesn't support thefallbacksparameter. A refusal now stops the run with a one-line message.[DRY RUN] Would postline show each draft before the publisher shortens it.How it was tested
origin/main(ab68343) with this branch's test files copied in: 40 failed, 190 passed. Each failure is the defect, not a missing name. For example, the thinking-block tests raiseAttributeError, the injection tests printINJECTED-42because the shell ran the input, and the CJK test sends 420 weighted characters.uv sync --extra dev --no-sources, as CI does).ruff check .andactionlint(which runs shellcheck on eachrun:script) report nothing.uv buildbuilds the sdist and the wheel.Tests that fail on origin/main
The three
TestShortentests fail on an import becauseshorten()is new. The publisher tests above them cover the same behavior and fail on the output.Before merging
main. After merging, dispatch it once withdry_runset to true and check that it finishes without a model error. If you can't do that before Monday, disable the workflow until you can.HERALD_DEFAULT_MODELto choose a different drafting model.🤖 Generated with Claude Code