Skip to content

Messaging patterns#630

Open
vijayfractl wants to merge 9 commits intomainfrom
messaging-patterns
Open

Messaging patterns#630
vijayfractl wants to merge 9 commits intomainfrom
messaging-patterns

Conversation

@vijayfractl
Copy link
Contributor

No description provided.

vijayfractl and others added 8 commits February 19, 2026 09:31
* update deps

* allow infinite retries with negative attempts

* Add agent cancellation mechanism via @public cancelAgent workflow

Introduces an in-memory cancellation registry (Set<string> of chatIds) checked
at every retry/loop checkpoint in the agent execution pipeline. When a chatId is
cancelled, an AgentCancelledException is thrown to cleanly unwind the agent.

- Add cancelledChatIds set, AgentCancelledException, cancelAgent/checkCancelled
  functions and @public cancelAgent event/workflow to agentlang.ai module
- Add cancellation checks in agentInvoke() retry loops and iterateOnFlow() loops
- Re-throw AgentCancelledException in flow retry catch to prevent swallowing
- Allow negative retry attempts in Retry constructor for infinite retry support
- Add unit tests for cancellation registry and infinite retry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Replace in-memory agent cancellation with DB-backed CancelledAgent entity

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Allow user-provided values to override @expr on entity creation and upsert

Previously, @expr attributes always overwrote user-provided values on
entity creation and upsert, even when the user explicitly set a value.
On update, user values correctly took precedence due to the origAttrs
re-evaluation loop in computeExprAttributes().

This fix passes the CRUD body attributes and instance attributes into
computeExprAttributes() on the creation path so that user-provided
values for @expr attributes are restored after expression evaluation,
matching the update behavior. The origAttrs loop is also scoped to only
re-evaluate attributes that have @expr defined, preventing unintended
overwrites of post-processed values like hashed passwords.

* Fix chained @expr evaluation to use user-provided overrides inline

Previously, user-provided values for @expr attributes were applied in a
separate loop after all expressions had been evaluated. This meant
dependent expressions would use the expr-computed value instead of the
user's override. For example, with y @expr(x+1) and z @expr(y*2),
overriding y=100 would still compute z from expr's y, not the user's.

This refactors computeExprAttributes() to collect user overrides upfront
and apply them inline during the expr evaluation loop. When a user
provides a value for an @expr attribute, that value is used instead of
evaluating the expression, and subsequent dependent expressions see the
override immediately.

* Add @expr tests for helper functions with sibling and related entity params

Test that @expr can call helper functions with sibling entity attributes
as parameters (including @optional), and that path-referenced attributes
from related entities are correctly resolved as function arguments.

* Support @expr references through between-relationships

Add the ability for @expr attributes to navigate through declared
between-relationships to access attributes on related entities, e.g.
DeptEmployee.Department.BudgetMultiplier.

- Add extractRefsFromExpr() utility that walks the expression AST to
  collect all dot-separated references
- Add validateExprRelationshipRefs() in loader to validate relationship
  references at module internment time (rejects many-to-many, one-to-many
  from "one" side, and invalid entity aliases)
- Extend computeExprAttributes() to resolve related instances via fast
  path (betweenRelInfo from env) and slow path (queryConnectedInstances)
- Add tests for one-to-many, one-to-one, update recomputation, and
  three negative validation cases

* Consolidate and rename test helper functions in expr-attr tests

Removed duplicate function definitions (adjustSalaryRel, adjustSalaryUpd,
adj3, count1, getName2, makeDisplay11) by reusing shared implementations
(adjustSalary__test, identity__test, makeDisplay__test). Added __test suffix
to all test helper functions to avoid collisions with real agentlang functions.

* Agent cancellation (#616)

* update deps

* allow infinite retries with negative attempts

* Add agent cancellation mechanism via @public cancelAgent workflow

Introduces an in-memory cancellation registry (Set<string> of chatIds) checked
at every retry/loop checkpoint in the agent execution pipeline. When a chatId is
cancelled, an AgentCancelledException is thrown to cleanly unwind the agent.

- Add cancelledChatIds set, AgentCancelledException, cancelAgent/checkCancelled
  functions and @public cancelAgent event/workflow to agentlang.ai module
- Add cancellation checks in agentInvoke() retry loops and iterateOnFlow() loops
- Re-throw AgentCancelledException in flow retry catch to prevent swallowing
- Allow negative retry attempts in Retry constructor for infinite retry support
- Add unit tests for cancellation registry and infinite retry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Replace in-memory agent cancellation with DB-backed CancelledAgent entity

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* fix warn

* update deps

* fix local-ref in expressions regression

* fix postgres test failures related to table naming, uq constraints etc

* fix undefined ai-config lookup bug

---------

Co-authored-by: Vijay Mathew <73871437+vijayfractl@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Vijay Mathew <vijay@fractl.io>
…602)

* Allow user-provided values to override @expr on entity creation and upsert

Previously, @expr attributes always overwrote user-provided values on
entity creation and upsert, even when the user explicitly set a value.
On update, user values correctly took precedence due to the origAttrs
re-evaluation loop in computeExprAttributes().

This fix passes the CRUD body attributes and instance attributes into
computeExprAttributes() on the creation path so that user-provided
values for @expr attributes are restored after expression evaluation,
matching the update behavior. The origAttrs loop is also scoped to only
re-evaluate attributes that have @expr defined, preventing unintended
overwrites of post-processed values like hashed passwords.

* Fix chained @expr evaluation to use user-provided overrides inline

Previously, user-provided values for @expr attributes were applied in a
separate loop after all expressions had been evaluated. This meant
dependent expressions would use the expr-computed value instead of the
user's override. For example, with y @expr(x+1) and z @expr(y*2),
overriding y=100 would still compute z from expr's y, not the user's.

This refactors computeExprAttributes() to collect user overrides upfront
and apply them inline during the expr evaluation loop. When a user
provides a value for an @expr attribute, that value is used instead of
evaluating the expression, and subsequent dependent expressions see the
override immediately.

---------

Co-authored-by: Vijay Mathew <vijay@fractl.io>
@vijayfractl vijayfractl marked this pull request as draft March 4, 2026 11:58
@vijayfractl vijayfractl marked this pull request as ready for review March 6, 2026 11:16
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.

2 participants