Skip to content

Module Self Invocation #8030

Closed
Closed

Description

@aluzzardi

Currently, a module invokes itself through the native language (e.g. self.otherFunction), which completely bypasses dagger.

Instead, dagger could provide a proper mechanism for a module to invoke one of its own functions via the engine in order to get:

This could potentially also be useful for testing, TBD.

/cc @sipsma @vito @helderco

Activity

  1. aluzzardi commented on Jul 24, 2024

    @aluzzardi
    ContributorAuthor

    Thinking about the implementation, I think this would be a pretty big change for module authors. I guess that rather than calling their code directly, they would do something like:

    • dag.Self?
    • Or maybe a special extra argument (self, this) -- but this will feel "alien" to the native language
    • Or through some sorcery in codegen (language specific) to inject some kind of wrappers?

    Also, there's the question of state. If the user sets a variable in their own struct/object, is it going to be available to the invoked function?

  2. jedevc commented on Jul 29, 2024

    @jedevc
    Contributor

    I'm quite interested in this as well 🎉

    One idea I really liked is that we could integrate this through the module dependencies - you can install the module as a dependency as itself. So you could do dagger install ..

    One reason this is neat, is because then you can name your module of yourself as you like - Self, or This, or even FullNameOfModule. We could pick a semi-reasonable default, but then users can edit their dagger.json config.

    R.e. state - I think without a huge rework of the call mechanism, it'll have entirely different state, since it'll be in a different ExecOp. I think that's what we want - it should just be like any other call.

  3. added this to the next milestone on Jul 29, 2024
  4. kpenfound commented on Apr 10, 2025

    @kpenfound
    Contributor

    This is super impactful for building agents! Primarily because we want to be able to pass types from our current module to dag.Env.

    Talking with @TomChv live, it sounded like there could be some complexity with syncing module state between the current module and handling it somehow through dag.Self, however, I do think a simpler implementation where we just get the current module's types generated in the API would be enough to unlock a ton of potential.

  5. eunomie commented on May 2, 2025

    @eunomie
    Member

    The llm/env aspect (so basically "just" to have the types) is one thing we can start with. It will not allow to have a kind of dag.Self but it will unblock some of the current limitations.
    One first thing for that is to decouple the type registration on runtime modules. This is especially true for Go/Java SDK as they generate code for that, so it can be extracted in a different execution path. For python/typescript (I have to check on others) as it's currently done at runtime, it might be different. But maybe that could be a good thing to align all of them.
    So we can start by adding a new "capability" to the module runtime, with something like a TypeDefs addition to the interface and handle that in a smooth and backward compatible way.

    Then two main questions remain, one regarding the state, one regarding the types. The type returned by the codegen will not be the same as the local type. So it requires a kind of reconciliation between them. Maybe by using interfaces? Interfaces as in the languages, not dagger interfaces. But in a second time, after the types to be available at the codegen/introspection level first.

  6. locked and limited conversation to collaborators on Mar 24, 2026
  7. converted this issue into a discussion #12276 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions